New submission from Carl Drougge <[email protected]>:
If several threads try to start a multiprocessing.Pool at the same time when no
pool has been started before this often fails with an exception like this (the
exact import varies):
Exception in thread Thread-2:
Traceback (most recent call last):
File "/tmp/py3.9.0rc1/lib/python3.9/threading.py", line 950, in
_bootstrap_inner
self.run()
File "/tmp/py3.9.0rc1/lib/python3.9/threading.py", line 888, in run
self._target(*self._args, **self._kwargs)
File "/tmp/py3.9.0rc1/lib/python3.9/multiprocessing/context.py", line 118, in
Pool
from .pool import Pool
ImportError: cannot import name 'Pool' from partially initialized module
'multiprocessing.pool' (most likely due to a circular import)
(/tmp/py3.9.0rc1/lib/python3.9/multiprocessing/pool.py)
This happens even if Pool was imported before starting the threads and is new
in 3.9. It's easy to work around by starting a pool in the main thread before
starting the other threads.
I have attached a minimal example that triggers it. Tested on Debian stable and
FreeBSD 11.3.
----------
components: Library (Lib)
files: pool_error_on_3.9.py
messages: 375542
nosy: drougge
priority: normal
severity: normal
status: open
title: multiprocessing.Pool from concurrent threads failure on 3.9.0rc1
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file49401/pool_error_on_3.9.py
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue41567>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com