[3.12] gh-94777: Fix deadlock in ProcessPoolExecutor (GH-94784) (#106609)

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 6782fc0502)

Co-authored-by: Louis Paulot <55740424+lpaulot@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2023-07-10 15:49:07 -07:00 committed by GitHub
parent 68ca19061d
commit 90ea3be6fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 0 deletions

View file

@ -499,6 +499,10 @@ class _ExecutorManagerThread(threading.Thread):
for p in self.processes.values():
p.terminate()
# Prevent queue writing to a pipe which is no longer read.
# https://github.com/python/cpython/issues/94777
self.call_queue._reader.close()
# clean up resources
self.join_executor_internals()