gh-137884: Added threading.get_native_id on Illumos/Solaris#137927
Merged
serhiy-storchaka merged 14 commits intopython:mainfrom Aug 20, 2025
Merged
gh-137884: Added threading.get_native_id on Illumos/Solaris#137927serhiy-storchaka merged 14 commits intopython:mainfrom
serhiy-storchaka merged 14 commits intopython:mainfrom
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
furkanonder
reviewed
Aug 18, 2025
auvipy
reviewed
Aug 19, 2025
Co-authored-by: Furkan Onder <furkanonder@protonmail.com>
Co-authored-by: Furkan Onder <furkanonder@protonmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Contributor
Author
Could you explain that a bit? |
Member
Unfortunately, we don't have any working Solaris buildbots to confirm that those tests actually pass now. |
picnixz
reviewed
Aug 20, 2025
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Member
|
I tested on OpenIndiana. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes: #137884
This PR enables
threading.get_native_idon Illumos distributions and Solaris.Illumos/Solaris defines the
thr_selffunction which returns the thread ID, unique for the process:https://docs.oracle.com/cd/E36784_01/html/E36874/thr-self-3c.html
On OmniOS and Solaris,
thr_selfreturns the thread IDs from 1, incrementing it for each thread.Since it is not unique in the system, it is not usable by itself per Python doc:
https://docs.python.org/3/library/threading.html#threading.get_native_id
In order to make it unique within the system, I put the PID from
getpidin the higher 4 bytes, and thread ID fromthr_selfin the lower 4 bytes of the returnedunsigned long.getpiddoesn't return an error value, and it returnspid_twhich is 4 bytes (int) on Illumos/Solaris:https://docs.oracle.com/cd/E23824_01/html/821-1463/getpid-2.html
thr_selfdoesn't return an error value, and it returnsthread_twhich is 4 bytes (unsigned int) on Illumos/Solaris:https://docs.oracle.com/cd/E36784_01/html/E36874/thr-self-3c.html
With the changes in this PR,
test_native_id_after_forkinLib/test/test_threading.pypasses, which was skipped before.This PR does not introduce any new test faliures.