Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

test(core): read the controller row before closing the socket it asserts on

Petr Bauch1943b95ae086
diff --git a/core/tests/switch_core/management/test_controllers_across_processes.py b/core/tests/switch_core/management/test_controllers_across_processes.py
index 64fef5155..7d9da92eb 100644
--- a/core/tests/switch_core/management/test_controllers_across_processes.py
+++ b/core/tests/switch_core/management/test_controllers_across_processes.py
@@ -645,13 +645,19 @@ class TestTheRowNamesTheConnectionOpenedLast:
async with there.client() as elsewhere:
second = await open_connection(elsewhere, controller)
stream = await open_stream(there, controller, second)
- await take(stream, 1)
- await there.management.ledger.flush_all()
- written.set()
- await here.management.ledger.flush_all()
- await stream.aclose() # type: ignore[attr-defined]
+ try:
+ await take(stream, 1)
+ await there.management.ledger.flush_all()
+ written.set()
+ await here.management.ledger.flush_all()
+
+ # Read while the second socket is still attached: closing it
+ # queues its own disconnected write, which may land before the
+ # read and is not what this test is about.
+ row = await _controller_row(here, controller.controller_id)
+ finally:
+ await stream.aclose() # type: ignore[attr-defined]
- row = await _controller_row(here, controller.controller_id)
assert row.connection_id == second["connection_id"]
assert row.connection_process_id == there.management.lease.process_id
assert row.disconnected_at is None