summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Quinlan <brian@sweetapp.com>2020-01-28 00:50:37 (GMT)
committerGitHub <noreply@github.com>2020-01-28 00:50:37 (GMT)
commit884eb89d4a5cc8e023deaa65001dfa74a436694c (patch)
tree703b85a841527655442faff65a428d08d2b6ee7c
parent2824c45a0a020f12f27da7e7162e8636c21bf869 (diff)
downloadcpython-884eb89d4a5cc8e023deaa65001dfa74a436694c.zip
cpython-884eb89d4a5cc8e023deaa65001dfa74a436694c.tar.gz
cpython-884eb89d4a5cc8e023deaa65001dfa74a436694c.tar.bz2
bpo-39205: Tests that highlight a hang on ProcessPoolExecutor shutdown (#18221)
-rw-r--r--Lib/test/test_concurrent_futures.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py
index c973516..c8fa35e 100644
--- a/Lib/test/test_concurrent_futures.py
+++ b/Lib/test/test_concurrent_futures.py
@@ -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):