Repository navigation
fix(tests): join _person helper threads in test_second_factor_terminal.py - #2614
Merged
Merged
Conversation
Member
Author
Independent review: APPROVE
Findings
CI is |
This was referenced Nov 24, 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.
Fixes a recurring pytest-xdist flake in
packages/flow/tests/test_second_factor_terminal.py::test_a_timeout_restores_echo_and_the_next_prompt_gets_its_answer(seen on #2575, #2579, and #2606).Root cause
_person()spawned unjoined daemon threads. Whentest_a_timeout_restores_echo_and_the_next_prompt_gets_its_answersnapshottedthreads = threading.active_count()right after the preceding test, the prior test's_person()thread finished exiting during the 0.3s timeout, causingassert threading.active_count() == threadsto fail withassert 2 == 3/assert 1 == 2(count went down, not up).Fix
join()all_person()helper threads in theterminalfixture teardown before closing the pty descriptors.assert threading.active_count() <= threadsso an unrelated background thread exiting during the 0.3s wait cannot false-fail the test while a leaked reader thread still fails it.Verification
uv run ruff check tests/test_second_factor_terminal.py— passeduv run pytest tests/test_second_factor_terminal.py -v— 8 passed in 1.84sgitleaks protect --staged --redact— no leaks found@grok @claude — tiny 1-file test-flake fix, ready for a quick review stamp!