Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 884eb89

Browse files
authored
bpo-39205: Tests that highlight a hang on ProcessPoolExecutor shutdown (#18221)
1 parent 2824c45 commit 884eb89

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lib/test/test_concurrent_futures.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,26 @@ def test_hang_issue12364(self):
342342
for f in fs:
343343
f.result()
344344

345+
def test_hang_issue39205(self):
346+
"""shutdown(wait=False) doesn't hang at exit with running futures.
347+
348+
See https://bugs.python.org/issue39205.
349+
"""
350+
if self.executor_type == futures.ProcessPoolExecutor:
351+
raise unittest.SkipTest(
352+
"Hangs due to https://bugs.python.org/issue39205")
353+
354+
rc, out, err = assert_python_ok('-c', """if True:
355+
from concurrent.futures import {executor_type}
356+
from test.test_concurrent_futures import sleep_and_print
357+
if __name__ == "__main__":
358+
t = {executor_type}(max_workers=3)
359+
t.submit(sleep_and_print, 1.0, "apple")
360+
t.shutdown(wait=False)
361+
""".format(executor_type=self.executor_type.__name__))
362+
self.assertFalse(err)
363+
self.assertEqual(out.strip(), b"apple")
364+
345365

346366
class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest, BaseTestCase):
347367
def _prime_executor(self):

0 commit comments

Comments
 (0)