-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
ProcessPoolExecutor deadlock when a child process crashes while data is being sent in call queue #94777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
gpshead
pushed a commit
that referenced
this issue
Jul 10, 2023
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jul 10, 2023
Fixes a hang in multiprocessing process pool executor when a child process crashes and code could otherwise block on writing to the pipe. See pythonGH-94777 for more details. (cherry picked from commit 6782fc0) Co-authored-by: Louis Paulot <[email protected]>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jul 10, 2023
Fixes a hang in multiprocessing process pool executor when a child process crashes and code could otherwise block on writing to the pipe. See pythonGH-94777 for more details. (cherry picked from commit 6782fc0) Co-authored-by: Louis Paulot <[email protected]>
carljm
pushed a commit
that referenced
this issue
Jul 10, 2023
) gh-94777: Fix deadlock in ProcessPoolExecutor (GH-94784) Fixes a hang in multiprocessing process pool executor when a child process crashes and code could otherwise block on writing to the pipe. See GH-94777 for more details. (cherry picked from commit 6782fc0) Co-authored-by: Louis Paulot <[email protected]>
carljm
pushed a commit
that referenced
this issue
Jul 10, 2023
) gh-94777: Fix deadlock in ProcessPoolExecutor (GH-94784) Fixes a hang in multiprocessing process pool executor when a child process crashes and code could otherwise block on writing to the pipe. See GH-94777 for more details. (cherry picked from commit 6782fc0) Co-authored-by: Louis Paulot <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug report
When using a ProcessPoolExecutor with forked child processes, if one of the child processes suddenly dies (segmentation fault, not a Python exception) and if simultaneously data is being sent into the call queue, then the parent process hangs forever.
Reproduction
In Python 3.8.10 it raises a BrokenProcessPool exception whereas in 3.9.13 and 3.10.5 it hangs.
Analysis
When a crash happens in a child process, all workers are terminated and they stop reading in communication pipes. However if data is being send in the call queue, the call queue thread which writes data from buffer to pipe (
multiprocessing.queues.Queue._feed
) can get stuck insend_bytes(obj)
when the unix pipe it's writing to is full._ExecutorManagerThread
is blocked inself.join_executor_internals()
on linecpython/Lib/concurrent/futures/process.py
Line 515 in da49128
self.terminate_broken()
). The main thread itself is blocked oncpython/Lib/concurrent/futures/process.py
Line 775 in da49128
__exit__
method of the Executor.Proposed solution
Drain call queue buffer either in
terminate_broken
method before callingjoin_executor_internals
or in queueclose
method.I will create a pull request with a possible implementation.
Your environment
Linked PRs
The text was updated successfully, but these errors were encountered: