Re: Thread Dump of a python process
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread Dump of a python process
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread Dump of a python process
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. -- View this message in context: http://www.nabble.com/Thread-Dump-of-a-python-process-t1089322.html#a2868401 Sent from the Python - python-list forum at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list
Re: Thread Dump of a python process
Shanon wrote: > I would to know if there're some way to have a dump of all the threads > started by a python process. I want to see the TID corresponding of each > thread because I need them to get the CPU time of each thread by the command > top. threading.enumerate() will return a list of all threading.Thread objects that have been created (including the main one), but Thread's do not currently store the identified of the underlying thread (created by a call to thread.start_new_thread(). You could easily subclass Thread to provide your own .start() which does that, and perhaps modify __repr__ to output that instead of the id() value. Check the source in threading.py if this approach sounds useful. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Thread Dump of a python process
Hi, I would to know if there're some way to have a dump of all the threads started by a python process. I want to see the TID corresponding of each thread because I need them to get the CPU time of each thread by the command top. Thanks -- View this message in context: http://www.nabble.com/Thread-Dump-of-a-python-process-t1089322.html#a2840609 Sent from the Python - python-list forum at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list