]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-39205: Tests that highlight a hang on ProcessPoolExecutor shutdown (#18221)
authorBrian Quinlan <brian@sweetapp.com>
Tue, 28 Jan 2020 00:50:37 +0000 (16:50 -0800)
committerGitHub <noreply@github.com>
Tue, 28 Jan 2020 00:50:37 +0000 (16:50 -0800)
Lib/test/test_concurrent_futures.py

index c97351636e86921258817f45b426b8acb496cbc5..c8fa35e9eeafa752c7a5852b59f47d2fd1b5304b 100644 (file)
@@ -342,6 +342,26 @@ class ExecutorShutdownTest:
         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(
+                "Hangs due to https://bugs.python.org/issue39205")
+
+        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__))
+        self.assertFalse(err)
+        self.assertEqual(out.strip(), b"apple")
+
 
 class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest, BaseTestCase):
     def _prime_executor(self):