[New-bugs-announce] [issue45914] Very first multiprocessing example not working on Windows 11
Chang Zhou
report at bugs.python.org
Sat Nov 27 23:37:54 EST 2021
New submission from Chang Zhou <quattrozhou at gmail.com>:
Very first multiprocessing example not working on Windows 11
https://docs.python.org/3/library/multiprocessing.html
from multiprocessing import Pool
def f(x):
return x*x
if __name__ == '__main__':
with Pool(5) as p:
print(p.map(f, [1, 2, 3]))
Tried Python 3.7, 3.8, 3.9, 3.10
Also tried Ubuntu which works fine.
But on Windows (clean installed python):
>>> from multiprocessing import Pool
>>> def f(x):
... return x*x
...
>>> with Pool(5) as p:
... print(p.map(f, [1, 2, 3]))
...
Process SpawnPoolWorker-14:
Process SpawnPoolWorker-13:
Traceback (most recent call last):
Process SpawnPoolWorker-15:
File "C:\Program Files\Python39\lib\multiprocessing\process.py", line 315, in _bootstrap
self.run()
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\multiprocessing\process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "C:\Program Files\Python39\lib\multiprocessing\process.py", line 315, in _bootstrap
self.run()
File "C:\Program Files\Python39\lib\multiprocessing\pool.py", line 114, in worker
task = get()
File "C:\Program Files\Python39\lib\multiprocessing\process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "C:\Program Files\Python39\lib\multiprocessing\queues.py", line 368, in get
return _ForkingPickler.loads(res)
File "C:\Program Files\Python39\lib\multiprocessing\pool.py", line 114, in worker
task = get()
AttributeError: Can't get attribute 'f' on <module '__main__' (built-in)>
File "C:\Program Files\Python39\lib\multiprocessing\queues.py", line 368, in get
return _ForkingPickler.loads(res)
AttributeError: Can't get attribute 'f' on <module '__main__' (built-in)>
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\multiprocessing\process.py", line 315, in _bootstrap
self.run()
File "C:\Program Files\Python39\lib\multiprocessing\process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "C:\Program Files\Python39\lib\multiprocessing\pool.py", line 114, in worker
task = get()
File "C:\Program Files\Python39\lib\multiprocessing\queues.py", line 368, in get
return _ForkingPickler.loads(res)
AttributeError: Can't get attribute 'f' on <module '__main__' (built-in)>
----------
components: Windows
messages: 407186
nosy: paul.moore, quattrozhou, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Very first multiprocessing example not working on Windows 11
type: crash
versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45914>
_______________________________________
More information about the New-bugs-announce
mailing list