diff options
author | nullptr <3621629+0x0L@users.noreply.github.com> | 2021-09-20 18:30:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-20 18:30:19 (GMT) |
commit | 0bfa1106acfcddc03590e1f5d6789dbad3affe70 (patch) | |
tree | 3fd58f08fd64ef7affed051a3ba3dbc0f86e5e18 /Lib/test/test_concurrent_futures.py | |
parent | 9510e6f3c797b4398aaf58abc1072b9db0a644f9 (diff) | |
download | cpython-0bfa1106acfcddc03590e1f5d6789dbad3affe70.zip cpython-0bfa1106acfcddc03590e1f5d6789dbad3affe70.tar.gz cpython-0bfa1106acfcddc03590e1f5d6789dbad3affe70.tar.bz2 |
bpo-45021: Fix a hang in forked children (GH-28007)
_global_shutdown_lock should be reinitialized in forked children
Diffstat (limited to 'Lib/test/test_concurrent_futures.py')
-rw-r--r-- | Lib/test/test_concurrent_futures.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py index b0df12c..84209ca 100644 --- a/Lib/test/test_concurrent_futures.py +++ b/Lib/test/test_concurrent_futures.py @@ -911,6 +911,20 @@ class ThreadPoolExecutorTest(ThreadPoolMixin, ExecutorTest, BaseTestCase): self.assertEqual(len(executor._threads), 1) executor.shutdown(wait=True) + @unittest.skipUnless(hasattr(os, 'register_at_fork'), 'need os.register_at_fork') + def test_hang_global_shutdown_lock(self): + # bpo-45021: _global_shutdown_lock should be reinitialized in the child + # process, otherwise it will never exit + def submit(pool): + pool.submit(submit, pool) + + with futures.ThreadPoolExecutor(1) as pool: + pool.submit(submit, pool) + + for _ in range(50): + with futures.ProcessPoolExecutor(1, mp_context=get_context('fork')) as workers: + workers.submit(tuple) + class ProcessPoolExecutorTest(ExecutorTest): |