Skip to content

The agent that grows with you

refactor(gateway): hoist watchdog constants to the canonical import; drop dead or-fallbacks

Kshitij Kapoor999703fd43ab
diff --git a/gateway/run.py b/gateway/run.py
index de35fc3a0c8..ba6a87e4875 100644
--- a/gateway/run.py
+++ b/gateway/run.py
@@ -2689,6 +2689,9 @@ from gateway.platforms.base import (
)
from gateway.shutdown_watchdog import (
DEFAULT_HEARTBEAT_INTERVAL_S,
+ DEFAULT_LOOP_WATCHDOG_INTERVAL_S,
+ DEFAULT_LOOP_WATCHDOG_MAX_STRIKES,
+ DEFAULT_LOOP_WATCHDOG_TIMEOUT_S,
_arm_loop_floor_timer,
arm_shutdown_watchdog,
loop_heartbeat_forever,
@@ -12349,25 +12352,24 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatew
watchdog = getattr(self, "_loop_liveness_watchdog", None)
if watchdog is None or not watchdog.is_alive():
try:
- from gateway.shutdown_watchdog import (
- DEFAULT_LOOP_WATCHDOG_INTERVAL_S as _WD_INTERVAL,
- DEFAULT_LOOP_WATCHDOG_MAX_STRIKES as _WD_STRIKES,
- DEFAULT_LOOP_WATCHDOG_TIMEOUT_S as _WD_TIMEOUT,
- )
-
- interval = _WD_INTERVAL
- timeout = _WD_TIMEOUT
- strikes = _WD_STRIKES
- if config is not None:
- interval = getattr(
- config, "loop_watchdog_probe_interval_s", _WD_INTERVAL
- ) or _WD_INTERVAL
- timeout = getattr(
- config, "loop_watchdog_probe_timeout_s", _WD_TIMEOUT
- ) or _WD_TIMEOUT
- strikes = getattr(
- config, "loop_watchdog_max_strikes", _WD_STRIKES
- ) or _WD_STRIKES
+ # getattr defaults cover the config=None / bare-object test
+ # path; config-loaded values are already validated+clamped
+ # by GatewayConfig.from_dict, so no re-clamping here.
+ interval = getattr(
+ config,
+ "loop_watchdog_probe_interval_s",
+ DEFAULT_LOOP_WATCHDOG_INTERVAL_S,
+ )
+ timeout = getattr(
+ config,
+ "loop_watchdog_probe_timeout_s",
+ DEFAULT_LOOP_WATCHDOG_TIMEOUT_S,
+ )
+ strikes = getattr(
+ config,
+ "loop_watchdog_max_strikes",
+ DEFAULT_LOOP_WATCHDOG_MAX_STRIKES,
+ )
self._loop_liveness_watchdog = start_loop_liveness_watchdog(
loop,
probe_interval=float(interval),