From b827fc565c796851f29377773c07d69fc6308ca4 Mon Sep 17 00:00:00 2001 From: ciregenz Date: Fri, 3 Jul 2026 15:24:00 -0700 Subject: [PATCH] [eric] 9router: watchdog probes from a thread (sync HTTP confirm could stall the event loop 2s mid-stream) --- backend/apps/nine_router/process.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/apps/nine_router/process.py b/backend/apps/nine_router/process.py index 933a8827..5784d017 100644 --- a/backend/apps/nine_router/process.py +++ b/backend/apps/nine_router/process.py @@ -387,14 +387,16 @@ async def p_watchdog_loop() -> None: false-negative while a busy router streams, and acting on one bad probe would rotate a LIVE router's request log and burn a duplicate spawn attempt.""" failures = 0 + p_loop = asyncio.get_running_loop() while True: await asyncio.sleep(P_WATCHDOG_BACKOFF_SECONDS if failures >= 3 else P_WATCHDOG_INTERVAL_SECONDS) try: - if is_running(): + # is_running()'s HTTP confirm is SYNC and can stall 2s while the router is busy streaming; a periodic pulse must never block the event loop, so probe from a thread. + if await p_loop.run_in_executor(None, is_running): failures = 0 continue await asyncio.sleep(2) - if is_running(): + if await p_loop.run_in_executor(None, is_running): failures = 0 continue logger.warning("9Router watchdog: router is down (confirmed twice); reviving")