-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
gh-114271: Make _thread.ThreadHandle
thread-safe in free-threaded builds
#115190
Merged
Merged
Changes from 9 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
cf6491c
Make `_thread.ThreadHandle` thread-safe in free-threaded builds
mpage e86dde8
Don't use PyOnceFlag post fork
mpage 9a61e20
Check for self-join outside of the once flag
mpage bcf66ce
Fix grammar and formatting
mpage 7f9720d
Update comment.
mpage 092c2eb
Account for handles being cleared after fork
mpage 77da31d
Move implementations of `_PyEventRc` functions out of header
mpage 321a4e0
Track all states of the handle in the enum
mpage cd0372c
Remove `detach()` method
mpage 7badb2d
Don't need to atomically initialize state in ThreadHandle ctor
mpage 9d35990
Remove unneeded function
mpage e554c5e
Don't need atomics in dtor
mpage 147a192
Elaborate on use of `thread_is_exiting` in `ThreadHandleObject` defin…
mpage 1fe27ce
Use sequential consistency for operations on state
mpage 9ec6d23
Merge branch 'main' into gh-114271-_thread-ThreadHandle
mpage a46b727
Remove `_join_lock` attribute
mpage 61d9fa9
Add reference to more details for self-join test
mpage f6bfa08
Assign explicit values for ThreadHandle states
mpage 1cc0f2e
Detail why non-atomic state access is safe in the destructor
mpage 3fbf119
Document the purpose of bootstate
mpage 9d21444
Mark handles running before decrefing args
mpage File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
This is interesting... our docs already claim that threads can be joined multiple times. So I wonder why this existing test logic was previously explicitly checking for an error here.
In this sense this change aligns with what our docs claim so a behavior change here could be seen as a bugfix. I do not expect anyone to be depending on subsequent join()s of a thread raising regardless.