From 643910afe33ca7dec9cfc1c9116d8b960510e093 Mon Sep 17 00:00:00 2001 From: kshitij <82637225+kshitijk4poor@users.noreply.github.com> Date: Sat, 8 Aug 2026 13:27:59 +0530 Subject: [PATCH] refactor(gateway): narrow worker-start guard to Exception Thread.start() failure is RuntimeError; catching BaseException here swallowed KeyboardInterrupt/SystemExit without re-raise (unlike _worker, which forwards them into the future). --- gateway/platforms/base.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gateway/platforms/base.py b/gateway/platforms/base.py index abe30e02435be..470fde9abfcb3 100644 --- a/gateway/platforms/base.py +++ b/gateway/platforms/base.py @@ -3535,11 +3535,13 @@ class BasePlatformAdapter(ABC): name="media-history-lookup", daemon=True, ).start() - except BaseException: - # Thread could not be started (e.g. thread exhaustion). The - # worker never ran, so its finally-release never fires — release - # the admission permit here to avoid leaking it permanently, and - # fail open like every other path in this helper. + except Exception: + # Thread could not be started (e.g. thread exhaustion — start() + # raises RuntimeError). The worker never ran, so its + # finally-release never fires — release the admission permit here + # to avoid leaking it permanently, and fail open like every other + # path in this helper. (Unlike _worker's BaseException forwarding, + # swallowing here must not eat KeyboardInterrupt/SystemExit.) admission.release() logger.warning( "[%s] Could not start media-delivery history lookup worker "