Thread Dump of a python process

Peter Hansen peter at engcorp.com
Fri Feb 10 08:26:10 EST 2006


Shanon wrote:
> Thank you for your info. Now I have read that a simple call os.getpid()
> returned the linux identifier of the thread in latest python versions, but
> I'm using Python 2.3 and 2.4 and this call returns always the same id 
> I only want to take the pid of the thread but isn't as easier as it seems.

I believe the underlying call to thread.start_new_thread() already 
returns the thread identifier that you want, but I haven't tried it 
recently and don't recall for sure.  To use this, however, you'd have to 
patch the source or subclass, as I mentioned.

I did this once and stored the result in the Thread as an attribute 
called .threadId and don't recall any problem using that.

-Peter




More information about the Python-list mailing list