Skip to content

fix: preserve capture fixture output on thread timeouts - #212

Open
Arham-Begani wants to merge 1 commit into
pytest-dev:mainfrom
Arham-Begani:fix/fixture-capture-timeout-output
Open

Arham-Begani wants to merge 1 commit into
pytest-dev:mainfrom
Arham-Begani:fix/fixture-capture-timeout-output

Conversation

@Arham-Begani

@Arham-Begani Arham-Begani commented Oct 19, 2026 •

Copy link
Copy Markdown

Fixes #172.

Thread timeouts can lose output buffered by capsys, capfd, capsysbinary or capfdbinary when the process exits. With --capture=no, fixture capture can also swallow the timeout diagnostics.

This flushes the active capture fixture before reading captured output, then keeps global and fixture capture disabled while reporting the timeout. The existing stack dump and exit code 1 are preserved.

Nine subprocess tests cover the four fixtures with fd capture and --capture=no, plus running without the capture plugin. They use a real timer and process exit. Upstream CI passed all ten Python 3.10–3.14 Linux/Windows jobs at commit 2252ccb.

@Arham-Begani

Copy link
Copy Markdown
Author

Could a maintainer review the focused thread-timeout capture fix when convenient? At 2252ccb0d3ac8419923040857ef9c46dfddd5ad6, all ten upstream Python 3.10–3.14 Linux/Windows jobs pass.

The change preserves output held by capsys/capfd and their binary variants before the process exits, including --capture=no, while keeping the existing stack dump and exit code. The nine subprocess regressions use the real timer and process exit; eight reproduce the loss before the fix, and the no-capture-plugin control already passes. The scope stays limited to thread-timeout teardown.

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.

@Arham-Begani

Copy link
Copy Markdown
Author

Following up on the October 20 review request for 2252ccb0. The upstream Test workflow passes, and the thread-timeout output-capture fix and its subprocess regressions are unchanged.

Could a maintainer review when convenient, or let me know if an adjustment is needed?

This follow-up was prepared with AI assistance.

@flub

flub commented Oct 31, 2026

Copy link
Copy Markdown
Member

If you want to help this issue along please re-write the original into something reasonable human-like. The current description is just way to long and difficult to parse and make sense of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggestion: Using capturemanager.global_and_fixture_disabled

2 participants