Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check the number of currently running threads in Python? [duplicate]

Possible Duplicate:
python - how to get the numebr of active threads started by specific class?

I'm new in python, i want to get count of running threads at any time...is there any built in support for this or i have to maintain it manually (e.g. count veriable...) ?

like image 840
Sufyan Ali Avatar asked Sep 18 '12 12:09

Sufyan Ali


People also ask

How do I see the number of threads running in Python?

In Python, the method threading. active_co unt() from the threading module is used to count the currently active or running threads.

How do I find the number of active threads?

The java. lang. Thread. activeCount() method returns the number of active threads in the current thread's thread group.

How do I make a list of threads in Python?

Creating Thread Using Threading ModuleDefine a new subclass of the Thread class. Override the __init__(self [,args]) method to add additional arguments. Then, override the run(self [,args]) method to implement what the thread should do when started.

Which method is used to retrieve the list of all active threads?

In the java console, hit Ctrl-Break. It will list all threads plus some information about the heap.


1 Answers

threading.active_count() seems to be what you're looking for :

Return the number of Thread objects currently alive

like image 187
Cédric Julien Avatar answered Sep 18 '22 12:09

Cédric Julien