3
votes

Currently i can list my processes with a simple python script:

import os os.system("Tasklist")

I would like to list all the threads associated with those processes, if any. The count of threads per process might be sufficient.

Would someone direct me where i might find this information.

Thank You.

1

1 Answers

4
votes

You can use the psutil module (download here) for cross-platform process information delivery.

After installing, use the following code to get the thread count of any process id.

import psutil
for proc in psutil.process_iter():
    print proc.name+' ['+str(proc.get_num_threads())+' threads]'