﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37510	Parallel test runner should report failure for work interrupted on a dead worker	Jacob Walls		"When manually testing the fix for #27734 (06463d3c11b3ce132075283d5f9368a269d66343), we engineered parallel test workers to die by creating them with `maxtasksperchild=1`. Now I realize that all we did was engineer a failure ''after'' the work has been completed and reported back to the test suite.

What we should have tested was a worker that dies *before* it reports success. Before #27734, we would have a loud failure. After #27734, we recover gracefully, but without reporting the results of the tests that were underway. This would lead to a misleading successful run, or more likely, a hang while waiting for the result.

I think we can keep the work from #27734 to recover gracefully and finish running all suites, but only as long as we actually report a failure for the interrupted tests.

Bug in 06463d3c11b3ce132075283d5f9368a269d66343.

{{{#!diff
diff --git a/tests/test_runner/test_parallel.py b/tests/test_runner/test_parallel.py
index df8532d4c6..0f29dca018 100644
--- a/tests/test_runner/test_parallel.py
+++ b/tests/test_runner/test_parallel.py
@@ -376,3 +376,19 @@ class ParallelTestSuiteTest(SimpleTestCase):
             pts.run(test_result)
 
         self.assertIn(""ValueError: woops"", test_result.errors[0][1])
+
+    def test_worker_exit_fails_run(self):
+        suite = ParallelTestSuite([TestSuite([TestCase()])], processes=1)
+        suite.serialized_aliases = set()
+        result = TestResult()
+        with mock.patch(""multiprocessing.Pool"") as mock_pool:
+            pool = mock_pool.return_value.__enter__.return_value
+            pool._pool = [mock.Mock(pid=101, exitcode=17)]
+            pool.imap_unordered.return_value.next.side_effect = [
+                multiprocessing.TimeoutError,
+                AssertionError(""The runner kept waiting after a worker died.""),
+            ]
+            suite.run(result)
+
+        msg = ""--parallel was unable to run all tests due to dead workers.""
+        self.assertIn(msg, result.errors[0][1])
}}}
{{{#!py
AssertionError: The runner kept waiting after a worker died.
}}}"	Bug	new	Testing framework	dev	Release blocker			Ahmed Mohamed jbligh	Unreviewed	0	0	0	0	0	0
