The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(tui_gateway): move the poller-rebuild invariant into its own file; map contributor
Tekniumebec691b7a1c
diff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]new file mode 100644index 00000000000..8ae63b3f875--- /dev/null+++ b/contributors/emails/[email protected]@@ -0,0 +1 @@+ranggaoscardiff --git a/tests/tui_gateway/test_tui_gateway_server.py b/tests/tui_gateway/test_tui_gateway_server.pyindex d04edd4e8ad..ae3b3d01329 100644--- a/tests/tui_gateway/test_tui_gateway_server.py+++ b/tests/tui_gateway/test_tui_gateway_server.py@@ -4917,52 +4917,6 @@ def _session(agent=None, **extra):}-def test_session_rebuild_stops_previous_notification_poller(monkeypatch):- """Rebuilding the agent for a live session re-enters _start_session_services; the previous- poller's stop event must be set before the record's ``_notif_stop`` is replaced (#138806).- Otherwise the orphaned poller keeps draining the process-global completion queue for the- session (two live loops per rebuild) until the session itself is finalized — close can only- signal the newest event."""- monkeypatch.setattr(server, "_notify_session_boundary", lambda *a, **k: None)- sess = _session()- server._sessions["sid_rebuild"] = sess- try:- server._start_session_services("sid_rebuild", "session-key", sess)- first_stop = sess["_notif_stop"]- assert not first_stop.is_set() # a fresh session really starts its poller running-- # Agent rebuild for the SAME session (in-session /model switch, resume, late MCP refresh).- server._start_session_services("sid_rebuild", "session-key", sess)- second_stop = sess["_notif_stop"]- assert second_stop is not first_stop- assert first_stop.is_set() # the previous poller was stopped, not orphaned-- # The old loop wakes at most every 0.5s; give it its real deadline to exit.- first_thread = next(- thread- for _stop, thread in list(server._notification_pollers)- if thread.name == "tui-notif-poller-sid_rebuild")- deadline = time.time() + 3.0- while first_thread.is_alive() and time.time() < deadline:- time.sleep(0.05)- assert not first_thread.is_alive(), "the stopped previous poller never exited"- live = [- thread- for _stop, thread in list(server._notification_pollers)- if thread.name == "tui-notif-poller-sid_rebuild" and thread.is_alive()- ]- assert len(live) == 1, f"expected exactly one live poller, got {len(live)}"-- # Session close can only signal the newest stop event — which now stops the only live poller.- second_stop.set()- live[0].join(timeout=3.0)- assert not live[0].is_alive()- finally:- for stop, thread in list(server._notification_pollers):- stop.set()- thread.join(timeout=1.0)--def test_session_close_commits_memory_and_fires_finalize_hook(monkeypatch):calls = {"hooks": []}