Determining thread id on Linux

Kristóf Stróbl stroblk at t-mobile.hu
Thu Jan 19 13:03:12 EST 2006


Hi!

I'm working under RedHat Linux (Advanced Server 3.0, kernel 2.4) and would like to determine thread identifiers in my multithreaded application. The "ps -efm" shell command lists every thread id of my process, but I do not know how to get them from Python. os.getpid() returns the same number even if called from different threads. thread.get_ident() returns different numbers if called from different threads, but these numbers do not correspond to the thread ids seen by the OS.

Is there a way to get the thread ids from Python, or do I have to write a C extension module to get them? 

Thanks,
Kristóf Stróbl



More information about the Python-list mailing list