Skip to content

The agent that grows with you

fix(gateway): wall-clock bound in the loop read test meets the 2 s floor; shutdown comment names the API-server executor

Teknium6c26e007d945
diff --git a/gateway/run_shutdown.py b/gateway/run_shutdown.py
index 5349c173f87..27e37700ae5 100644
--- a/gateway/run_shutdown.py
+++ b/gateway/run_shutdown.py
@@ -2059,8 +2059,8 @@ class GatewayShutdownMixin(GatewaySessionEndMixin):
)
return
logger.info("Shutdown phase: executor quiesced at +%.2fs", ctx.elapsed())
- # Cron jobs (scheduler pool), API-server runs and deferred hygiene workers (both on the loop's
- # default executor) never touch self._executor, so the join above cannot see them. A writer that
+ # Cron jobs (scheduler pool), API-server runs (their own bounded executor) and deferred hygiene
+ # workers (the loop's default executor) never touch self._executor, so the join above cannot see them. A writer that
# outlived the drain is mid-write for the same #101093 reasons; the drain already spent its
# budget, so no second wait — leave the handles open (#102198). The API count is the snapshot
# taken before the adapters were released; a run whose handler task was cancelled at disconnect
diff --git a/tests/agent/test_token_read_barrier_on_loop.py b/tests/agent/test_token_read_barrier_on_loop.py
index 36eca7956ad..f10f1b59e9e 100644
--- a/tests/agent/test_token_read_barrier_on_loop.py
+++ b/tests/agent/test_token_read_barrier_on_loop.py
@@ -36,7 +36,7 @@ def test_loop_thread_session_read_does_not_wait_for_a_stuck_writer(tmp_path):
return row, listed, time.monotonic() - started
row, listed, elapsed = asyncio.run(read_on_loop())
- assert elapsed < 1.0, f"loop-thread read waited {elapsed:.2f}s on the token writer"
+ assert elapsed < 2.0, f"loop-thread read waited {elapsed:.2f}s on the token writer"
assert row is not None and row["id"] == "s-loop"
assert any(r["id"] == "s-loop" for r in listed)