pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/6782fc050281205734700a1c3e13b123961ed15b

aa60c69660fa.css" /> gh-94777: Fix deadlock in ProcessPoolExecutor (#94784) · python/cpython@6782fc0 · GitHub
Skip to content

Commit 6782fc0

Browse files
authored
gh-94777: Fix deadlock in ProcessPoolExecutor (#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.
1 parent 9d58225 commit 6782fc0

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

Lib/concurrent/futures/process.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ def terminate_broken(self, cause):
499499
for p in self.processes.values():
500500
p.terminate()
501501

502+
# Prevent queue writing to a pipe which is no longer read.
503+
# https://github.com/python/cpython/issues/94777
504+
self.call_queue._reader.close()
505+
502506
# clean up resources
503507
self.join_executor_internals()
504508

Lib/test/test_concurrent_futures.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,11 @@ def _crash(delay=None):
11721172
faulthandler._sigsegv()
11731173

11741174

1175+
def _crash_with_data(data):
1176+
"""Induces a segfault with dummy data in input."""
1177+
_crash()
1178+
1179+
11751180
def _exit():
11761181
"""Induces a sys exit with exitcode 1."""
11771182
sys.exit(1)
@@ -1371,6 +1376,19 @@ def test_shutdown_deadlock_pickle(self):
13711376
# dangling threads
13721377
executor_manager.join()
13731378

1379+
def test_crash_big_data(self):
1380+
# Test that there is a clean exception instad of a deadlock when a
1381+
# child process crashes while some data is being written into the
1382+
# queue.
1383+
# https://github.com/python/cpython/issues/94777
1384+
self.executor.shutdown(wait=True)
1385+
data = "a" * support.PIPE_MAX_SIZE
1386+
with self.executor_type(max_workers=2,
1387+
mp_context=self.get_context()) as executor:
1388+
self.executor = executor # Allow clean up in fail_on_deadlock
1389+
with self.assertRaises(BrokenProcessPool):
1390+
list(executor.map(_crash_with_data, [data] * 10))
1391+
13741392

13751393
create_executor_tests(ExecutorDeadlockTest,
13761394
executor_mixins=(ProcessPoolForkMixin,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix hanging :mod:`multiprocessing` ``ProcessPoolExecutor`` when a child process crashes while data is being written in the call queue.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy