From 9d7aa687895a4b67eab331902d860d85edb3c084 Mon Sep 17 00:00:00 2001 From: JeffreyChen Date: Mon, 2 Nov 2026 15:40:13 +0800 Subject: [PATCH] Wait for the presence server to retire its source after a refused client The server drops the accepted connection and then retires its source. The test checked for the retirement as soon as the client saw the close, and on the release PR's Windows 3.13 runner it had not landed yet. It now waits up to five seconds for both the source close and the failed status. --- test/unit_test/headless/test_agent_presence_server.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/unit_test/headless/test_agent_presence_server.py b/test/unit_test/headless/test_agent_presence_server.py index 8f90b3767..c26b4a7cd 100644 --- a/test/unit_test/headless/test_agent_presence_server.py +++ b/test/unit_test/headless/test_agent_presence_server.py @@ -196,7 +196,13 @@ def start(self): client = connected(pipe) try: assert client.closed.wait(1) - assert 'source-close' in events and server.status()['failed'] + # The server drops the connection first and retires its source after it: + # on a slow runner the client sees the close before the retirement lands. + deadline = time.monotonic() + 5 + while time.monotonic() < deadline and not ('source-close' in events and server.status()['failed']): + threading.Event().wait(0.01) + assert 'source-close' in events + assert server.status()['failed'] finally: client.close() with pytest.raises(AgentTaskError):