Thread Dump of a python process

Peter Hansen peter at engcorp.com
Fri Feb 10 08:29:38 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.

Oops, please ignore my other reply to this post.  I didn't grab the 
start_new_thread() result, but instead grabbed the result of 
thread.get_ident() and stored that.  The docs claim this is not a value 
that necessarily relates to anything in the outside world ("Return the 
`thread identifier' of the current thread. This is a nonzero integer. 
Its value has no direct meaning; it is intended as a magic cookie ...") 
so if it happens to match the thread id from the OS's point of view, 
it's an implementation detail you couldn't rely on.

So the general idea I gave might be useful, but I don't know precisely 
how to do exactly what you are asking.  Sorry.

-Peter




More information about the Python-list mailing list