Reputation: 45
I wrote a program with Python and it uses multi-threads, i want to know how many threads were executed with the timing and all of the statistics, is there a way to use the debugger to have those results ?
PS: i am using PyCharm.
Upvotes: 3
Views: 9393
Reputation: 4469
Assuming you are using the threading
module rather than bare thread
s, you can use threading.active_count()
as follows:
num_threads = threading.active_count() # Python 3.x
num_threads = threading.activeCount() # Python 2.x
to get the amount of threads. To get the threads themselves, use threading.enumerate()
:
for th in threading.enumerate():
# do whatever.
As far as timing and other statistics, you may have to track these manually, it looks like Thread
objects are fairly scant of meta-data.
Upvotes: 7