Get number of workers from process Pool in python multiprocessing module
14,792
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
Author by
gc5
Updated on June 05, 2022Comments
-
gc5 almost 2 years
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