Skip to content
Advertisement

How to get the number of active threads started by specific class?

code looks like below:

JavaScript

Is there a way to get the number of threads being active by originating class ?

Advertisement

Answer

This is a minor modification of Doug Hellman’s multiprocessing ActivePool example code (to use threading). The idea is to have your workers register themselves in a pool, unregister themselves when they finish, using a threading.Lock to coordinate modification of the pool’s active list:

JavaScript

yields

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement