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 attribute 'pid' that can be accessed (which would serve your purpose).<br>
<br>Please note that *this is NOT a thread id*<br>
<br><br><div class="gmail_quote">On Fri, Jan 30, 2009 at 11:33 AM, Alejandro <span dir="ltr"><<a href="mailto:alejandro.weinstein@gmail.com">alejandro.weinstein@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Jan 30, 9:11 am, Jean-Paul Calderone <<a href="mailto:exar...@divmod.com">exar...@divmod.com</a>> wrote:<br>
> [clarification about threads]<br>
<br>
Thank you for the clarification. I will reformulate my question:<br>
<br>
pstree and also ntop (but not top) show a number for each thread, like<br>
for instance:<br>
<br>
$pstree -p 9197<br>
python(9197)€ˆ€{python}(9555)<br>
<div class="Ih2E3d">             †€{python}(9556)<br>
             †€{python}(9557)<br>
             †€{python}(9558)<br>
             †€{python}(9559)<br>
             †€{python}(9560)<br>
             †€{python}(9561)<br>
             †€{python}(9562)<br>
             †€{python}(9563)<br>
</div>             „€{python}(9564)<br>
<br>
Is is possible to get the number corresponding to each thread?<br>
<br>
The reason I am interested is because one of my thread is hogging the<br>
CPU, and want to find which one is the culprit.<br>
<div><div></div><div class="Wj3C7c"><br>
Regards,<br>
Alejandro.<br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>