Repository navigation
fix: preserve capture fixture output on thread timeouts - #212
Open
Arham-Begani wants to merge 1 commit into
Open
Arham-Begani wants to merge 1 commit into
Arham-Begani wants to merge 1 commit into
Conversation
Author
|
Could a maintainer review the focused thread-timeout capture fix when convenient? At The change preserves output held by No additional code change is proposed here. The implementation, validation and this follow-up used AI assistance, as disclosed in the PR. Thanks for considering the review. |
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 #172.
Problem
timeout_timer()suspends only global capture and reads only that buffer. A test usingcapsys,capfd,capsysbinaryorcapfdbinarykeeps its output in the fixture's buffer. The process then exits without fixture teardown, discarding the output that could explain why the test hung. With--capture=no, an activecapfdfixture can also capture the timeout diagnostics themselves.This is reproducible on current main
1bbaf767df44cacdb401aba5490ffa7b97fd7337: print distinct stdout/stderr markers through a capture fixture, then sleep with--timeout=1 --timeout-method=thread. Neither marker survives the timeout.Change
capturemanager.global_and_fixture_disabled()while writing diagnostics, flushing streams and exiting. AnExitStackkeeps that context active through the existing exception handler andfinallyblock and supports running without the capture plugin.--capture=no, plus a no-capture-plugin control.The change is limited to the thread-timeout termination path.
Validation
Windows, CPython 3.13.15, pytest 9.1.1:
os._exitis not mocked.git diff --checkpasses.Fork CI: https://github.com/Arham-Begani/pytest-timeout/actions/runs/39199866683
All 10 matrix jobs passed: Python 3.10, 3.11, 3.12, 3.13 and 3.14 on Linux and Windows, including the Linux signal-based tests skipped locally.
The Python 3.12 Linux job reports 61 passed, 1 skipped and 6 expected failures; Windows reports 44 passed and 24 skipped. Checkout logs confirm both jobs used
2252ccb.The fork's workflow definition adds a manual dispatch input, and its checkout step explicitly selects source commit
2252ccb0d3ac8419923040857ef9c46dfddd5ad6. That trigger-only change lives on the fork's main branch; it is not part of this PR. The workflow otherwise runs the project's Python 3.10–3.14 matrix on Linux and Windows.AI assistance
An AI coding assistant reproduced, implemented, tested, reviewed and drafted this contribution with the account owner's authorization. No human review or personal authorship certification is claimed. The issue was checked for competing work and the reproduction/claim was posted before implementation.