Skip to content

Commit d035c6b

Browse files
committed
Add test
1 parent 5564811 commit d035c6b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Lib/test/test_concurrent_futures/test_thread_pool.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,25 @@ def submit(pool):
6666
with futures.ProcessPoolExecutor(1, mp_context=mp.get_context('fork')) as workers:
6767
workers.submit(tuple)
6868

69+
@support.requires_fork()
70+
@unittest.skipUnless(hasattr(os, 'register_at_fork'), 'need os.register_at_fork')
71+
@support.requires_resource('cpu')
72+
def test_process_fork_from_a_threadpool(self):
73+
# bpo-43944: clear concurrent.futures.thread._threads_queues after fork,
74+
# otherwise child process will try to join parent thread
75+
def fork_process_and_return_exitcode():
76+
p = mp.get_context('fork').Process(target=lambda: 1)
77+
p.start()
78+
p.join()
79+
return p.exitcode
80+
81+
with futures.ThreadPoolExecutor(1) as pool:
82+
process_exitcode = pool.submit(fork_process_and_return_exitcode).result()
83+
84+
self.assertEqual(process_exitcode, 0)
85+
86+
87+
6988
def test_executor_map_current_future_cancel(self):
7089
stop_event = threading.Event()
7190
log = []

0 commit comments

Comments
 (0)