Skip to content

Commit e9ff212

Browse files
gpsheadclaude
andcommitted
gh-83386: Enable test_hang_gh83386 for ProcessPoolExecutor
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. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 1b4135a commit e9ff212

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
@@ -115,20 +115,21 @@ def test_hang_gh83386(self):
115115
116116
See https://github.com/python/cpython/issues/83386.
117117
"""
118-
if self.executor_type == futures.ProcessPoolExecutor:
119-
raise unittest.SkipTest(
120-
"Hangs, see https://github.com/python/cpython/issues/83386")
121-
122118
rc, out, err = assert_python_ok('-c', """if True:
123119
from concurrent.futures import {executor_type}
124120
from test.test_concurrent_futures.test_shutdown import sleep_and_print
125121
if __name__ == "__main__":
126-
if {context!r}: multiprocessing.set_start_method({context!r})
127-
t = {executor_type}(max_workers=3)
122+
context = '{context}'
123+
if context == "":
124+
t = {executor_type}(max_workers=3)
125+
else:
126+
from multiprocessing import get_context
127+
t = {executor_type}(max_workers=3,
128+
mp_context=get_context(context))
128129
t.submit(sleep_and_print, 1.0, "apple")
129130
t.shutdown(wait=False)
130131
""".format(executor_type=self.executor_type.__name__,
131-
context=getattr(self, 'ctx', None)))
132+
context=getattr(self, 'ctx', '')))
132133
self.assertFalse(err)
133134
self.assertEqual(out.strip(), b"apple")
134135

@@ -243,8 +244,6 @@ def test_thread_names_default(self):
243244
t.join()
244245

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

0 commit comments

Comments
 (0)