This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: multiprocessing.dummy missing cpu_count
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: davin, flox, johnwiseman, vstinner
Priority: normal Keywords:

Created on 2017-03-21 22:59 by johnwiseman, last changed 2022-04-11 14:58 by admin.

Messages (2)
msg289950 - (view) Author: John Wiseman (johnwiseman) Date: 2017-03-21 22:59
The documentation for the multiprocessing.dummy module says that it "replicates the API of multiprocessing."  In Python 2.7, I can import multiprocessing.dummy and use the cpu_count function:

$ python2
Python 2.7.12 (default, Oct 29 2016, 19:21:06)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing.dummy as mp
>>> mp.cpu_count()
8

But in Python 3.6, multiprocessing.dummy is missing cpu_count:

$ python3
Python 3.6.0 (default, Mar 21 2017, 13:27:21)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing.dummy as mp
>>> mp.cpu_count()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'multiprocessing.dummy' has no attribute 'cpu_count'

I would expect that multiprocessing.dummy would have cpu_count, since that function is available in multiprocessing, and it's there in Python 2.7.

It looks like it was removed in commit 04842a8, "Remove unused or redundant imports in concurrent.futures and multiprocessing" (Florent Xicluna 5 years ago).  Maybe the removal was inadvertent?

I realize there are several workarounds, but based on the documentation and the behavior of previous versions, I wouldn't have expected this breaking change.
msg297640 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-07-04 10:48
multiprocessing.dummy lacks many symbols:

>>> set(multiprocessing.__all__) - set(multiprocessing.dummy.__all__)
{'RawArray', 'set_forkserver_preload', 'ProcessError', 'RawValue', 'BufferTooShort', 'reducer', 'set_executable', 'Array', 'cpu_count', 'get_all_start_methods', 'get_start_method', 'AuthenticationError', 'Value', 'set_start_method', 'allow_connection_pickling', 'get_logger', 'SimpleQueue', 'TimeoutError', 'log_to_stderr', 'get_context'}
History
Date User Action Args
2022-04-11 14:58:44adminsetgithub: 74054
2017-07-04 10:48:25vstinnersetnosy: + vstinner
messages: + msg297640
2017-03-22 05:34:04serhiy.storchakasetnosy: + flox, davin
2017-03-21 22:59:06johnwisemancreate