Skip to content
11 changes: 7 additions & 4 deletions Lib/test/test_concurrent_futures/test_thread_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import multiprocessing.util
import os
import threading
import warnings
import unittest
from concurrent import futures
from test import support
Expand Down Expand Up @@ -67,14 +68,16 @@ def submit(pool):
workers.submit(tuple)

@support.requires_fork()
@unittest.skipUnless(hasattr(os, 'register_at_fork'), 'need os.register_at_fork')
@support.requires_resource('cpu')
@unittest.skipUnless(hasattr(os, "register_at_fork"), "need os.register_at_fork")
@support.requires_resource("cpu")
def test_process_fork_from_a_threadpool(self):
# bpo-43944: clear concurrent.futures.thread._threads_queues after fork,
# otherwise child process will try to join parent thread
def fork_process_and_return_exitcode():
p = mp.get_context('fork').Process(target=lambda: 1)
p.start()
# Ignore the warning about fork with threads.
with warnings.catch_warnings(category=DeprecationWarning, action="ignore"):
p = mp.get_context("fork").Process(target=lambda: 1)
p.start()
p.join()
return p.exitcode

Expand Down
Loading