Closed
Description
The multiprocessing
module documentation contains the following example:
>>> from multiprocessing import Pool
>>> p = Pool(5)
>>> def f(x):
... return x*x
...
>>> with p:
... p.map(f, [1,2,3])
Process PoolWorker-1:
Process PoolWorker-2:
Process PoolWorker-3:
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
AttributeError: 'module' object has no attribute 'f'
AttributeError: 'module' object has no attribute 'f'
AttributeError: 'module' object has no attribute 'f'
Actually, it is outdated. It was so in Python 2, but in Python 3 before 3.12 you get AttributeError with different message
AttributeError: Can't get attribute 'f' on <module '__main__' (built-in)>
and in 3.12 you get
AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status
Done