bpo-36084: add native thread ID (TID) to threading.Thread objects (V2) - #13463
Conversation
…jects now have a tid property (kernel thread ID)
…c operation, since the functionality now supports Windows as well; cleaned up and clarified doc notes, updated version added number (3.8)
… ID functions depending on system type and functional availability; Threading module now returns `None` if the thread has not been started, or if the Native ID functionality does not exist for the current operating system.
…e on the target system.
|
Per @bedevere-bot – |
|
Thanks for making the requested changes! @vstinner: please review the changes made to this pull request. |
|
@vstinner please advise if there are any additional suggestions you have or changes that should be implemented before the merge. |
I expect the reason it broke AIX - is because AIX supports - for nearly 30 years is my guess (not known if it was already in AIX 3.X, but always in AIX 4.X). The 'key' issue being that <pthread.h> needs to be first (or -D_THREAD_SAFE, which may be 'better' to ensure that all C-code is compiled "thread-safe" when using gcc. I normally use xlc_r, which sets _THREAD_SAFE - but I cannot assume that gcc (which is what the AIX bots currently use) are compiling everything "thread-safe". Anyway, moving forward - how can I best contribute some code specific to AIX. Never tried working "together" before. |
|
To be clear, in all the POSIX-based platforms that I’ve worked with to build this feature (notably excluding AIX, which I have zero experience with), Can you confirm whether or not AIX has the capability to return the integral ID, or whether the |
|
Looking at docs, I think this might be what we’re looking for: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.basetrf2/thread_self.htm I will look into this and see if it’d be easy to add for this PR. |
|
I'd recommend tackling AIX as a separate PR. |
|
Either way :) In that case, I think this is mostly good to go (pending review of course). |

This is the second version of PR #11993 (original reverted due to test failures on unsupported operating systems).
cc @vstinner @pitrou
From the original PR:
https://bugs.python.org/issue36084