From 949604c1ad85166f81eeec99d7c79893c368a872 Mon Sep 17 00:00:00 2001 From: Thea Flowers Date: Tue, 11 Sep 2018 12:18:14 -0700 Subject: [PATCH] Fix race condition where pending Ack IDs can be modified by another thread. --- .../pubsub_v1/subscriber/_protocol/streaming_pull_manager.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py b/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py index 21a8f98851a0..17d1a2cad166 100644 --- a/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py +++ b/pubsub/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py @@ -379,7 +379,9 @@ def _get_initial_request(self): # Any ack IDs that are under lease management need to have their # deadline extended immediately. if self._leaser is not None: - lease_ids = self._leaser.ack_ids + # Explicitly copy the list, as it could be modified by another + # thread. + lease_ids = list(self._leaser.ack_ids) else: lease_ids = []