This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add native_thread_id to PyThreadState
Type: enhancement Stage: resolved
Components: C API Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Gabriele Tornetta, pitrou, python-dev, shreyanavigyan, vstinner
Priority: normal Keywords: patch

Created on 2021-04-17 09:18 by Gabriele Tornetta, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 25458 merged python-dev, 2021-04-17 14:14
Messages (2)
msg391276 - (view) Author: Gabriele N Tornetta (Gabriele Tornetta) * Date: 2021-04-17 09:18
I would like to propose adding the native_id field to the PyThreadState structure to store the result of PyThread_get_thread_native_id. On some systems, like Linux, it is not easy to retrieve this information from outside of the Python interpreter process.

Tools like Austin (https://github.com/P403n1x87/austin) could benefit from this for CPU time sampling. Currently, if one wants to retrieve the TID from a PyThreadState instance is to regard thread_id as a pointer to a struct pthread structure, loop over all the Python threads to find the one that has the PID for TID and infer the offset of the tid field within struct pthread, which is not ideal.
msg394438 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-05-26 14:40
New changeset 90a6c07cb20114dda801f027a90df839225751cb by Gabriele N. Tornetta in branch 'main':
bpo-43879: Add native_thread_id field to PyThreadState (GH-25458)
https://github.com/python/cpython/commit/90a6c07cb20114dda801f027a90df839225751cb
History
Date User Action Args
2022-04-11 14:59:44adminsetgithub: 88045
2021-05-26 14:40:40vstinnersetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.11, - Python 3.10
2021-05-26 14:40:22vstinnersetnosy: + vstinner
messages: + msg394438
2021-04-18 02:33:06rhettingersetnosy: + pitrou
2021-04-17 14:26:09Gabriele Tornettasettitle: Add native_id to PyThreadState -> Add native_thread_id to PyThreadState
2021-04-17 14:14:46python-devsetkeywords: + patch
nosy: + python-dev

pull_requests: + pull_request24184
stage: patch review
2021-04-17 11:04:45shreyanavigyansetnosy: + shreyanavigyan
2021-04-17 09:18:44Gabriele Tornettacreate