Get thread pid

Christian Heimes lists at
Fri Jan 30 21:40:49 CET 2009

Alejandro schrieb:
> Hi:
> I have Python program running under Linux, that create several
> threads, and I want to now the corresponding PID of the threads.

May I ask why you want to get the TID? You can't do anything useful with
it. You can't kill a thread safely, neither from within Python nor from
the outside world. thread.get_ident() gives you an id. On pthread based
systems the function uses pthread_self().
For TLS, Python has builtin classes that are hooked into Python's
internal threading system.

More information about the Python-list mailing list