The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(raft): disconnect no longer sleeps on the event loop waiting for a bridge child to go
kshitijk4poor86488a3c8fd3
diff --git a/hermes_cli/web_routers/messaging.py b/hermes_cli/web_routers/messaging.pyindex e9041ccbd3e..ae0f685c18c 100644--- a/hermes_cli/web_routers/messaging.py+++ b/hermes_cli/web_routers/messaging.py@@ -455,8 +455,9 @@ def _terminate_whatsapp_pairing(proc: subprocess.Popen | None) -> None:proc.kill()proc.wait(timeout=3)if proc.poll() is not None:- # Stopped; one we failed to stop stays covered by the owner-death supervisor.- release_process_group_once_empty(proc.pid, proc=proc)+ # Stopped; one we failed to stop stays covered by the owner-death supervisor. timeout=0:+ # callers run on the event loop.+ release_process_group_once_empty(proc.pid, proc=proc, timeout=0)def _fail_whatsapp_pairing(pairing_id: str, error: str, *, proc=None, unless=_WHATSAPP_ONBOARDING_TERMINAL_STATUSES) -> None:diff --git a/plugins/platforms/raft/adapter.py b/plugins/platforms/raft/adapter.pyindex d9381cc1b96..d4dd5ae6a09 100644--- a/plugins/platforms/raft/adapter.py+++ b/plugins/platforms/raft/adapter.py@@ -404,7 +404,9 @@ class RaftAdapter(BasePlatformAdapter):logger.exception("[raft] Error stopping bridge")if proc.poll() is not None:# Stopped by us; a bridge we failed to stop stays covered by the owner-death supervisor.- release_process_group_once_empty(proc.pid, proc=proc)+ # timeout=0: disconnect() runs this on the event loop, which must not sleep on a child+ # the TERM to the leader alone left in its group.+ release_process_group_once_empty(proc.pid, proc=proc, timeout=0)async def send(self, chat_id: str, content: str, reply_to: Optional[str] = None,metadata: Optional[dict[str, Any]] = None) -> SendResult:diff --git a/tests/hermes_cli/test_owned_agent_subprocs.py b/tests/hermes_cli/test_owned_agent_subprocs.pyindex 80f8831fd45..a2950096075 100644--- a/tests/hermes_cli/test_owned_agent_subprocs.py+++ b/tests/hermes_cli/test_owned_agent_subprocs.py@@ -12,6 +12,7 @@ import osimport signalimport subprocessimport sys+import timefrom pathlib import Pathimport psutil@@ -268,7 +269,11 @@ def test_a_stopped_bridge_whose_child_survived_stays_covered(monkeypatch, tmp_paa._bridge_process = bridgetry:wait_until(receipt.exists, what="helper receipt")+ started = time.monotonic()a._stop_bridge()+ # disconnect() runs this on the event loop: the live helper must not make it sleep out the+ # release wait (it took a full second with the default timeout).+ assert time.monotonic() - started < 0.8, "_stop_bridge() blocked on the surviving helper"assert bridge.poll() is not None, "_stop_bridge() left the bridge running"assert released == [], "a group with a live helper was released from the owner-death supervisor"finally: