gh-120973: Fix thread-safety issues with threading.local#121655
Conversation
This is a small refactoring to the current design that allows us to avoid manually iterating over threads.
ambv
left a comment
There was a problem hiding this comment.
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. |
colesbury
left a comment
There was a problem hiding this comment.
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? |
colesbury
left a comment
There was a problem hiding this comment.
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