Skip to content

The agent that grows with you

refactor(gateway): narrow worker-start guard to Exception

kshitij643910afe33c
diff --git a/gateway/platforms/base.py b/gateway/platforms/base.py
index abe30e02435..470fde9abfc 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 "