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.

Author pitrou
Recipients Delgan, pitrou, vstinner
Date 2020-04-28.10:43:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1588070590.14.0.700323063589.issue40399@roundup.psfhosted.org>
In-reply-to
Content
I can reproduce on Ubuntu 18.04 with git master.

Here is a better example which clearly shows the issue:
https://gist.github.com/pitrou/d9784d5ec679059cd02fce4b38ea2fa6

After a few runs, you'll see that the child Process hangs when trying to flush the standard streams:
Timeout (0:00:01)!
Thread 0x00007efbff6c0080 (most recent call first):
  File "/home/antoine/cpython/default/Lib/multiprocessing/util.py", line 435 in _flush_std_streams
  File "/home/antoine/cpython/default/Lib/multiprocessing/process.py", line 335 in _bootstrap
  File "/home/antoine/cpython/default/Lib/multiprocessing/popen_fork.py", line 71 in _launch
  File "/home/antoine/cpython/default/Lib/multiprocessing/popen_fork.py", line 19 in __init__
  File "/home/antoine/cpython/default/Lib/multiprocessing/context.py", line 276 in _Popen
  File "/home/antoine/cpython/default/Lib/multiprocessing/context.py", line 224 in _Popen
  File "/home/antoine/cpython/default/Lib/multiprocessing/process.py", line 121 in start
  File "/home/antoine/cpython/default/bpo40399.py", line 25 in <module>
Child process failed!


@Delgan, mixing processes and threads is problematic with the default settings.  See here:
https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods

"""Note that safely forking a multithreaded process is problematic."""

If you call `multiprocessing.set_start_method("forkserver")` at the start of your program, the problem will disappear.
History
Date User Action Args
2020-04-28 10:43:10pitrousetrecipients: + pitrou, vstinner, Delgan
2020-04-28 10:43:10pitrousetmessageid: <1588070590.14.0.700323063589.issue40399@roundup.psfhosted.org>
2020-04-28 10:43:10pitroulinkissue40399 messages
2020-04-28 10:43:09pitroucreate