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 = []