Question

I am trying to figure a way to get the number of processes directly from an instance of multiprocessing.Pool class in Python.. Is there a way to do it?

The documentation doesn't show anything related.

Thanks

Was it helpful?

Solution

You can use _processes attribute:

>>> import multiprocessing
>>> pool = multiprocessing.Pool()
>>> pool._processes
8

The return value is same for multiprocessing.cpu_count() unless you specified process count when creating Pool object.

>>> multiprocessing.cpu_count()
8
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top