The stream-idle watchdog tests can hang in fixture teardown when their HTTP server accepts a connection without a complete request. The stop event only releases do_POST, while server.shutdown() waits indefinitely for a handler blocked reading the request line.
Set a one-second read timeout on the fixture's accepted sockets. The deliberate SSE stall remains controlled by its existing event. A shared, typed generator lets both the pytest fixture and a focused regression exercise the same server lifecycle. The regression waits for the connection to be accepted, runs teardown off the event loop, and verifies that it finishes while the idle client socket is still open. Its failure cleanup closes that socket and waits for teardown so the test reports a failure instead of hanging.
Validation:
- Before the timeout fix, the new regression failed with
TimeoutErrorand completed its cleanup. python -m pytest -q tests/test_stream_idle_timeout.py: 7 passed.- Ruff format/check and
git diff --check: passed. - Focused Pyright: 14 existing diagnostics on both main and this branch; zero added or removed diagnostics by rule/message.
Tested on macOS with Python 3.12.14, frozen project dependencies, temporary HOME, and isolated environment. All HTTP traffic stayed on loopback with fixture credentials. This change does not establish which client lifecycle path left the original full-suite connection open; it ensures that such a connection cannot leave this fixture's teardown waiting indefinitely.
Fixes #1687
[Low impact] This test-only change appears safe to merge.
Summary
Bounds idle connections in the stream-watchdog test server.
No actionable issues were found. No tests were run during this review.
Reviews (1) · Last reviewed commit: "test: bound idle gateway connections dur..." · Reviewed by Greptile