[New-bugs-announce] [issue41567] multiprocessing.Pool from concurrent threads failure on 3.9.0rc1

Carl Drougge report at bugs.python.org
Mon Aug 17 07:37:30 EDT 2020


New submission from Carl Drougge <bugs.python.org at s.z42.net>:

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 <report at bugs.python.org>
<https://bugs.python.org/issue41567>
_______________________________________


More information about the New-bugs-announce mailing list