Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-130148: Addredirect_stdout(..., per_thread: bool = False)#144334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Liam-DeVoe wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromLiam-DeVoe:redirect-stdout-per-thread

Conversation

@Liam-DeVoe
Copy link
Contributor

@Liam-DeVoeLiam-DeVoe commentedJan 30, 2026
edited by bedevere-appbot
Loading

In#130148, there was discussion of what would be required to makeredirect_stdout thread-aware.#130148 (comment) proposed adding aper_thread: bool = False argument. This PR implements that argument.

To support interleavingper_thread=False andper_thread=True, this PR uses a slightly more complicated design involving walking up the stack of context managers to find the first one applicable to its thread.

As an example motivating usage, makingdoctest thread-safe becomes a ~one line change with this PR:https://github.com/python/cpython/compare/main...Liam-DeVoe:cpython:redirect-stdout-doctest?expand=1.

I think there's been previous discussion of whether this should live in CPython or be proven out in another project first. I don't know exactly where people have fallen on this. I opened a previous version of this code againstQuansight-Labs/pytest-run-parallel#167, but after discussion with@ngoldbaum it was unclear to us that pytest-run-parallel is the right place for this to live, rather than the standard library.

cc:@ngoldbaum@colesbury

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@Liam-DeVoe

[8]ページ先頭

©2009-2026 Movatter.jp