[New-bugs-announce] [issue40399] Program hangs if process created right after adding object to a Queue

Delgan report at bugs.python.org
Sun Apr 26 12:58:22 EDT 2020


New submission from Delgan <delgan.py at gmail.com>:

Hi.

I have a very basic program:
- one multiprocessing SimpleQueue
- one consumer thread
- one loop:
  - add one item to the queue
  - create a new process with itself add one item to the queue
  - wait for the process to end

For some unknown reason, it will hangs after some time. 

I know the docs said:

> This means that if you try joining that process you may get a deadlock unless you are sure that all items which have been put on the queue have been consumed. Similarly, if the child process is non-daemonic then the parent process may hang on exit when it tries to join all its non-daemonic children.

That's why I added "time.sleep(1)" inside the process, to make sure all items added by the child process are consumed. You can remove it and the hang will happen faster.


I'm using Python 3.8.2 on Linux. Forcing program to terminate with Ctrl+C (twice):

^CTraceback (most recent call last):
  File "bug.py", line 23, in <module>
    p.join()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 149, in join
    res = self._popen.wait(timeout)
  File "/usr/lib/python3.8/multiprocessing/popen_fork.py", line 47, in wait
    return self.poll(os.WNOHANG if timeout == 0.0 else 0)
  File "/usr/lib/python3.8/multiprocessing/popen_fork.py", line 27, in poll
    pid, sts = os.waitpid(self.pid, flag)
KeyboardInterrupt
^CError in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/popen_fork.py", line 27, in poll
    pid, sts = os.waitpid(self.pid, flag)
KeyboardInterrupt

----------
components: Library (Lib)
files: bug.py
messages: 367317
nosy: Delgan
priority: normal
severity: normal
status: open
title: Program hangs if process created right after adding object to a Queue
type: behavior
versions: Python 3.8
Added file: https://bugs.python.org/file49094/bug.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40399>
_______________________________________


More information about the New-bugs-announce mailing list