Re: Get thread pid

2009-02-02 Thread Alejandro
On Feb 2, 3:01 am, Ove Svensson wrote: > If you find a way to get to the real TID, that will be specific to > your architecture. > > If htop (or any other application) returns a TID, that is either > artificial or architecture specific. Right know I only need the TID for debugging under Linux. I

Re: Get thread pid

2009-02-02 Thread Ove Svensson
Alejandro writes: > On Jan 30, 1:40 pm, Christian Heimes wrote: >> May I ask why you want to get the TID? > > htop shows the TID of each thread. Knowing the TID allows me to know > which thread is hogging the CPU. If there is a better way to do this, > or there is something fundamentally wrong w

Re: Get thread pid

2009-02-01 Thread Alejandro
On Jan 30, 1:40 pm, Christian Heimes wrote: > May I ask why you want to get the TID? htop shows the TID of each thread. Knowing the TID allows me to know which thread is hogging the CPU. If there is a better way to do this, or there is something fundamentally wrong with this approach, please let

Re: Get thread pid

2009-02-01 Thread Alejandro
On Jan 30, 10:10 am, Jean-Paul Calderone wrote: >     >>> ctypes.CDLL('libc.so.6').syscall(224) Great! ctypes.CDLL('libc.so.6').syscall(224) does the trick. Thank you. Regards, Alejandro. -- http://mail.python.org/mailman/listinfo/python-list

Re: Get thread pid

2009-01-30 Thread Christian Heimes
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 no

Re: Get thread pid

2009-01-30 Thread Jean-Paul Calderone
On Fri, 30 Jan 2009 08:33:53 -0800 (PST), Alejandro wrote: On Jan 30, 9:11 am, Jean-Paul Calderone wrote: [clarification about threads] Thank you for the clarification. I will reformulate my question: pstree and also ntop (but not top) show a number for each thread, like for instance: $ps

Re: Get thread pid

2009-01-30 Thread ma
I think issue here is that you're invoking a system call (using either the subprocess module or os.popen*) from your threads. Those *are* external processes and will show up under pstree since they have a parent process. If you're using subprocess.Popen() the object that is returned has an attribut

Re: Get thread pid

2009-01-30 Thread Alejandro
On Jan 30, 9:11 am, Jean-Paul Calderone wrote: > [clarification about threads] Thank you for the clarification. I will reformulate my question: pstree and also ntop (but not top) show a number for each thread, like for instance: $pstree -p 9197 python(9197)€ˆ€{python}(9555) †€{pyth

Re: Get thread pid

2009-01-30 Thread ma
Actually, the command given "ps axH" uses H which shows threads as if they were processes. If you check the pid of these "processes," you would find that they are all equivalent. On Fri, Jan 30, 2009 at 9:56 AM, Alejandro wrote: > On Jan 30, 4:00 am, Ove Svensson wrote: > > Pidis a process iden

Re: Get thread pid

2009-01-30 Thread Jean-Paul Calderone
On Fri, 30 Jan 2009 06:56:10 -0800 (PST), Alejandro wrote: On Jan 30, 4:00 am, Ove Svensson wrote: Pidis a process identifier. Threads are not processes. All your threads execute within the context if a single process, hence they should have the samepid. Threads may have athreadid but it is n

Re: Get thread pid

2009-01-30 Thread Alejandro
On Jan 30, 4:00 am, Ove Svensson wrote: > Pidis a process identifier. Threads are not processes. All your threads > execute within the context if a single process, hence they should have > the samepid. Threads may have athreadid but it is not the same as thepid. According to this document (http:/

Re: Get thread pid

2009-01-30 Thread Ove Svensson
Alejandro writes: > Hi: > > I have Python program running under Linux, that create several > threads, and I want to now the corresponding PID of the threads. > > In each of the threads I have > > def run(self): > pid = os.getpid() > logger.critical('process ID: %s', pid) > > However, the

Re: Get thread pid

2009-01-29 Thread Gabriel Genellina
En Thu, 29 Jan 2009 14:04:49 -0200, Alejandro escribió: I have Python program running under Linux, that create several threads, and I want to now the corresponding PID of the threads. In each of the threads I have def run(self): pid = os.getpid() logger.critical('process ID: %s', pi

Get thread pid

2009-01-29 Thread Alejandro
Hi: I have Python program running under Linux, that create several threads, and I want to now the corresponding PID of the threads. In each of the threads I have def run(self): pid = os.getpid() logger.critical('process ID: %s', pid) However, the reported PID is the father number, not t