-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-132542: Set native thread ID after fork #132701
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
base: main
Are you sure you want to change the base?
Conversation
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.
Needs a blurb entry.
🤖 New build scheduled with the buildbot fleet by @ZeroIntensity for commit 6ebd095 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F132701%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-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.
LGTM
print(threading.current_thread().native_id, flush=True) | ||
assert threading.current_thread().native_id == threading.get_native_id() | ||
else: | ||
assert parent_thread_native_id == threading.current_thread().native_id |
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.
Since you want to assert on the child's output, explicitly wait for the child process.
try:
... asserts ...
finally:
os.waitpid(child_pid)
Since most of Python's runtime state, including thread-related data, is only consistent after
PyOS_AfterFork_Child()
is called, updatingnative_id
in theafter_fork
handler ensures correctness and aligns with Python’s existing fork-handling mechanisms.