Python thread

Adam Skutt askutt at gmail.com
Thu Sep 1 22:25:22 EDT 2011


On Sep 1, 5:14 pm, George <mydevgr... at gmail.com> wrote:
> Hi,
> Why doesn't python threads show an associated PID?  On spawning python
> threads using the threading module I can only see the main thread's pid on
> using top or ps unix command, no  subprocesses are displayed. In otherwords
> top or ps in not aware of any subprocesses created using threading module in
> python.

You probably need to run 'ps axm' or something similar to see to
threads associated with a processes on your system.

>
> Whereas in Java , creating threads will result in separate pid , these
> subprocesses can be listed using top or ps. Java threads get mapped to the
> cores in the system.

No.  It depends on your runtime, but if Java uses native threads, it
will have the same behavior as Python here. It also doesn't mean they
get mapped to cores in the system.  All it means is the operating
system is responsible for scheduling the threads and managing their
lifecycle.

Adam



More information about the Python-list mailing list