From 471ee4bb422ec4aa0f1aa1089540a1ad0b7d84f0 Mon Sep 17 00:00:00 2001 From: doomedraven Date: Thu, 10 Sep 2026 09:40:40 +0200 Subject: [PATCH] Simplify download retry mechanism in GCP PubSub service (#3224) Refactor download retry logic to simplify exception handling. --- utils/gcp_pubsub_service.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/utils/gcp_pubsub_service.py b/utils/gcp_pubsub_service.py index bd1a53f147c..2c7d3bc5c1e 100644 --- a/utils/gcp_pubsub_service.py +++ b/utils/gcp_pubsub_service.py @@ -340,16 +340,15 @@ def process_message(self, message: Any): # Retry download once with fresh client if TransportError/SSL issues occur success = False for attempt in range(2): - try: - if download_from_gcs(gcs_uri, temp_path, logger=mlog, client=self.storage_client): - success = True - break - except Exception as e: + if download_from_gcs(gcs_uri, temp_path, logger=mlog, client=self.storage_client): + success = True + break + else: if attempt == 0: - mlog.warning("Transient error during download, recreating client and retrying: %s", e) + mlog.warning("Transient error during download, recreating client and retrying") self._init_clients() else: - mlog.error("Persistent error during download: %s", e) + mlog.error("Persistent error during download after retries") if success: mlog.info("Download finished in %.2f seconds", time.time() - dl_start)