mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-09 13:21:42 +00:00
fix(mcp): iteration-bound the session-ready poll so frozen-clock tests can't spin forever
_wait_for_server_session_ready used a time.monotonic deadline; the circuit-breaker tests freeze monotonic, turning the loop into an infinite spin (300s SIGKILL in CI-parity runs). Bound by iteration count instead.
This commit is contained in:
parent
27beeb1830
commit
756dd75fbe
1 changed files with 8 additions and 3 deletions
|
|
@ -2836,8 +2836,12 @@ def _wait_for_server_session_ready(
|
|||
different so callers do not mistake the pre-reconnect, stale session for a
|
||||
fresh one.
|
||||
"""
|
||||
deadline = time.monotonic() + max(float(timeout), 0.0)
|
||||
while time.monotonic() < deadline:
|
||||
# Iteration-bounded rather than deadline-bounded: several tests (and the
|
||||
# circuit-breaker cooldown logic) monkeypatch time.monotonic to a frozen
|
||||
# clock, which would make a monotonic-deadline loop spin forever.
|
||||
poll_interval = 0.25
|
||||
iterations = max(1, int(max(float(timeout), 0.0) / poll_interval))
|
||||
for i in range(iterations):
|
||||
session = getattr(srv, "session", None)
|
||||
ready = getattr(srv, "_ready", None)
|
||||
is_ready = True
|
||||
|
|
@ -2848,7 +2852,8 @@ def _wait_for_server_session_ready(
|
|||
is_ready = True
|
||||
if session is not None and session is not old_session and is_ready:
|
||||
return True
|
||||
time.sleep(0.25)
|
||||
if i < iterations - 1:
|
||||
time.sleep(poll_interval)
|
||||
return False
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue