refactor(gateway): hoist watchdog constants to the canonical import; drop dead or-fallbacks
/simplify-code quality reviewer: _start_loop_liveness_guards re-imported the DEFAULT_LOOP_WATCHDOG_* constants locally although the file's canonical shutdown_watchdog import block already exists, and the 'or DEFAULT' guards re-clamped values GatewayConfig.from_dict already validates — unreachable for config-loaded values. getattr defaults keep the config=None test path working.
This commit is contained in:
+20
-18
@@ -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,
|
||||
# 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,
|
||||
)
|
||||
|
||||
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
|
||||
self._loop_liveness_watchdog = start_loop_liveness_watchdog(
|
||||
loop,
|
||||
probe_interval=float(interval),
|
||||
|
||||
Reference in New Issue
Block a user