-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
gh-137884: Added threading.get_native_id on Illumos/Solaris #137927
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
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 |
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.
shouldn't we also try extra test for this the change?
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>
Could you explain that a bit? |
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. 👍
Unfortunately, we don't have any working Solaris buildbots to confirm that those tests actually pass now. |
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
I tested on OpenIndiana. |
Fixes: #137884
This PR enables
threading.get_native_id
on Illumos distributions and Solaris.Illumos/Solaris defines the
thr_self
function 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_self
returns 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
getpid
in the higher 4 bytes, and thread ID fromthr_self
in the lower 4 bytes of the returnedunsigned long
.getpid
doesn't return an error value, and it returnspid_t
which is 4 bytes (int
) on Illumos/Solaris:https://docs.oracle.com/cd/E23824_01/html/821-1463/getpid-2.html
thr_self
doesn't return an error value, and it returnsthread_t
which 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_fork
inLib/test/test_threading.py
passes, which was skipped before.This PR does not introduce any new test faliures.