From a33f49c06f244fa700933ad21250be042299bec3 Mon Sep 17 00:00:00 2001 From: WuA Date: Tue, 27 Aug 2024 13:01:58 +0900 Subject: [PATCH] Update streaming_pull_manager.py to address NoneType A fix for https://github.com/googleapis/python-pubsub/issues/1238 --- .../subscriber/_protocol/streaming_pull_manager.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py b/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py index b8531db17..721466d55 100644 --- a/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py +++ b/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py @@ -941,7 +941,12 @@ def _shutdown(self, reason: Any = None) -> None: assert self._leaser is not None self._leaser.stop() - total = len(dropped_messages) + len( + if dropped_messages is not None: + total = len(dropped_messages) + else: + total = 0 + + total = total + len( self._messages_on_hold._messages_on_hold ) _LOGGER.debug(f"NACK-ing all not-yet-dispatched messages (total: {total}).")