-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-120973: Fix thread-safety issues with threading.local
#121655
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is a small refactoring to the current design that allows us to avoid manually iterating over threads.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, works for me. Read through the implementation, clever trick with the sentinel. I find it just a tiny bit uglier that thread state now is concerned with thread locals, but it makes sense given the problem this PR is solving.
🤖 New build scheduled with the buildbot fleet by @colesbury for commit 8d41fbc 🤖 If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I think the design looks good. Some comments below.
@colesbury - I think this should be good to go. Would you please have another look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'll wait until today's releases finish before merging this.
!buildbot AMD64 Ubuntu NoGIL Refleaks |
🤖 New build scheduled with the buildbot fleet by @colesbury for commit 9a7350d 🤖 The command will test the builders whose names match following regular expression: The builders matched are:
|
Thanks @mpage for the PR, and @colesbury for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…honGH-121655) This is a small refactoring to the current design that allows us to avoid manually iterating over threads. This should also fix pythongh-118490. (cherry picked from commit e059aa6) Co-authored-by: mpage <mpage@meta.com>
GH-122042 is a backport of this pull request to the 3.13 branch. |
|
This is a small refactoring to the current design that allows us to avoid manually iterating over threads.
This should also fix gh-118490.
threading.local()
implementation is not thread-safe in the free-threaded build #120973