Get number of workers from process Pool in python multiprocessing module

multiprocessing, python, threadpool

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

Problem

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

Original source

Related problems