summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-07-10 22:49:07 (GMT)
committerGitHub <noreply@github.com>2023-07-10 22:49:07 (GMT)
commit90ea3be6fbee1520dd3e9344c71123e15fcbe6f2 (patch)
tree4488a0a59746eb75c8c010359394e54dccec5073 /Lib/test
parent68ca19061d19345a72574a6c3849981213de212b (diff)
downloadcpython-90ea3be6fbee1520dd3e9344c71123e15fcbe6f2.zip
cpython-90ea3be6fbee1520dd3e9344c71123e15fcbe6f2.tar.gz
cpython-90ea3be6fbee1520dd3e9344c71123e15fcbe6f2.tar.bz2
[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 6782fc050281205734700a1c3e13b123961ed15b) Co-authored-by: Louis Paulot <55740424+lpaulot@users.noreply.github.com>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_concurrent_futures.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py
index a20cb84..39dbe23 100644
--- a/Lib/test/test_concurrent_futures.py
+++ b/Lib/test/test_concurrent_futures.py
@@ -1172,6 +1172,11 @@ def _crash(delay=None):
faulthandler._sigsegv()
+def _crash_with_data(data):
+ """Induces a segfault with dummy data in input."""
+ _crash()
+
+
def _exit():
"""Induces a sys exit with exitcode 1."""
sys.exit(1)
@@ -1371,6 +1376,19 @@ class ExecutorDeadlockTest:
# dangling threads
executor_manager.join()
+ def test_crash_big_data(self):
+ # Test that there is a clean exception instad of a deadlock when a
+ # child process crashes while some data is being written into the
+ # queue.
+ # https://github.com/python/cpython/issues/94777
+ self.executor.shutdown(wait=True)
+ data = "a" * support.PIPE_MAX_SIZE
+ with self.executor_type(max_workers=2,
+ mp_context=self.get_context()) as executor:
+ self.executor = executor # Allow clean up in fail_on_deadlock
+ with self.assertRaises(BrokenProcessPool):
+ list(executor.map(_crash_with_data, [data] * 10))
+
create_executor_tests(ExecutorDeadlockTest,
executor_mixins=(ProcessPoolForkMixin,