Skip to content

Commit 058a5c6

Browse files
miss-islingtongpsheadclaude
authored
[3.14] gh-83386: Enable test_hang_gh83386 for ProcessPoolExecutor (GH-152976) (#152983)
gh-83386: Enable test_hang_gh83386 for ProcessPoolExecutor (GH-152976) The hang this test guards against (interpreter exit after shutdown(wait=False) with running futures) was fixed for ProcessPoolExecutor by the executor management rewrite years ago, but the test still skipped it citing the issue. The skip also hid a latent NameError in the subprocess template, which only selects a start method in the process pool variants; rewrite it to use the same mp_context=get_context() shape as the sibling templates. Remove a stale comment claiming ProcessPoolExecutor often hangs with wait=False. (cherry picked from commit 548c731) Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 8a8c8ee commit 058a5c6

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

Lib/test/test_concurrent_futures/test_shutdown.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,21 @@ def test_hang_gh83386(self):
111111
112112
See https://github.com/python/cpython/issues/83386.
113113
"""
114-
if self.executor_type == futures.ProcessPoolExecutor:
115-
raise unittest.SkipTest(
116-
"Hangs, see https://github.com/python/cpython/issues/83386")
117-
118114
rc, out, err = assert_python_ok('-c', """if True:
119115
from concurrent.futures import {executor_type}
120116
from test.test_concurrent_futures.test_shutdown import sleep_and_print
121117
if __name__ == "__main__":
122-
if {context!r}: multiprocessing.set_start_method({context!r})
123-
t = {executor_type}(max_workers=3)
118+
context = '{context}'
119+
if context == "":
120+
t = {executor_type}(max_workers=3)
121+
else:
122+
from multiprocessing import get_context
123+
t = {executor_type}(max_workers=3,
124+
mp_context=get_context(context))
124125
t.submit(sleep_and_print, 1.0, "apple")
125126
t.shutdown(wait=False)
126127
""".format(executor_type=self.executor_type.__name__,
127-
context=getattr(self, 'ctx', None)))
128+
context=getattr(self, 'ctx', '')))
128129
self.assertFalse(err)
129130
self.assertEqual(out.strip(), b"apple")
130131

@@ -234,8 +235,6 @@ def test_thread_names_default(self):
234235
t.join()
235236

236237
def test_cancel_futures_wait_false(self):
237-
# Can only be reliably tested for TPE, since PPE often hangs with
238-
# `wait=False` (even without *cancel_futures*).
239238
rc, out, err = assert_python_ok('-c', """if True:
240239
from concurrent.futures import ThreadPoolExecutor
241240
from test.test_concurrent_futures.test_shutdown import sleep_and_print

0 commit comments

Comments
 (0)