From c07ddd03a8e17399c3bcd0806438df7e4838b6a3 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 27 Jan 2020 11:58:33 -0800 Subject: [PATCH 1/3] Add a test for a hang at exit --- Lib/test/test_concurrent_futures.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py index c97351636e8692..27096bef242791 100644 --- a/Lib/test/test_concurrent_futures.py +++ b/Lib/test/test_concurrent_futures.py @@ -342,6 +342,27 @@ def test_hang_issue12364(self): for f in fs: f.result() + def test_hang_issue39205(self): + """shutdown(wait=False) doesn't hang at exit with running futures. + + See https://bugs.python.org/issue39205. + """ + if self.executor_type == futures.ProcessPoolExecutor: + raise unittest.SkipTest("") + + rc, out, err = assert_python_ok('-c', """if True: + from concurrent.futures import {executor_type} + from test.test_concurrent_futures import sleep_and_print + if __name__ == "__main__": + t = {executor_type}(max_workers=3) + t.submit(sleep_and_print, 1.0, "apple") + t.shutdown(wait=False) + """.format(executor_type=self.executor_type.__name__)) + # Errors in atexit hooks don't change the process exit code, check + # stderr manually. + self.assertFalse(err) + self.assertEqual(out.strip(), b"apple") + class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest, BaseTestCase): def _prime_executor(self): From 7b5d53a666ee649292e71a62cd33ff1c7138b890 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 27 Jan 2020 12:00:00 -0800 Subject: [PATCH 2/3] Add a message for skip --- Lib/test/test_concurrent_futures.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py index 27096bef242791..7fb4c5a66cecb8 100644 --- a/Lib/test/test_concurrent_futures.py +++ b/Lib/test/test_concurrent_futures.py @@ -348,7 +348,8 @@ def test_hang_issue39205(self): See https://bugs.python.org/issue39205. """ if self.executor_type == futures.ProcessPoolExecutor: - raise unittest.SkipTest("") + raise unittest.SkipTest( + "Hangs due to https://bugs.python.org/issue39205") rc, out, err = assert_python_ok('-c', """if True: from concurrent.futures import {executor_type} From e8b6a063ea49435e9cd49abe8005c465511d2f23 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 27 Jan 2020 14:23:11 -0800 Subject: [PATCH 3/3] Remove incorrect comment --- Lib/test/test_concurrent_futures.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py index 7fb4c5a66cecb8..c8fa35e9eeafa7 100644 --- a/Lib/test/test_concurrent_futures.py +++ b/Lib/test/test_concurrent_futures.py @@ -359,8 +359,6 @@ def test_hang_issue39205(self): t.submit(sleep_and_print, 1.0, "apple") t.shutdown(wait=False) """.format(executor_type=self.executor_type.__name__)) - # Errors in atexit hooks don't change the process exit code, check - # stderr manually. self.assertFalse(err) self.assertEqual(out.strip(), b"apple")