Repository navigation
Drain temporary server requests before reusing pages - #416
Merged
Merged
Conversation
leaf-agent
reviewed
Sep 7, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The race the PR names is real and the mechanism is right — daemon_threads = False is what puts a handler thread on _Threads, so server_close() joins it. What comes with it is that close() is no longer bounded, and I could reproduce a hang on the fixture path this change is for. Details inline on start().
I'd rather not guess which way you want it resolved, so this is a comment rather than an approval. Say the word and I'll push whichever route you pick.
leaf-agent
approved these changes
Sep 7, 2026
This was referenced Sep 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Threaded temporary servers inherited
ThreadingHTTPServer's daemon request handlers, soclose()drained the accept loop but returned before active handlers exited. The browser fixture could then return a page toPagePoolwhile a news or state request was still finishing an atomic write, making reset race the writer's temporary file.Make request handlers non-daemon only for the in-process
start()mode, whereserver_close()can join them before the caller reuses or removes the page. A one-second socket timeout prevents an idle or incomplete client from making that join unbounded; the foregroundrun()mode keeps daemon handlers so an interrupted server process can still exit. The regressions pause an accepted request before an atomic page write and park an accepted connection before its request line, proving both sides of the shutdown contract.Verification:
uv run pytest tests(908 passed);uv run pytest -q -n0 tests/test_interact_server.py(96 passed);uv run pre-commit run --all-files; 242 affected browser cases at-n4(241 passed, with the sole failure being the suggestion-docking defect since fixed on main), followed by the nine formerly failing/reusing cases on the merged base (9 passed).