Skip to content

Commit 85d7b8f

Browse files
authored
Ignore the warning about fork with threads
1 parent 18b91ac commit 85d7b8f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Lib/test/test_concurrent_futures/test_thread_pool.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import multiprocessing.util
55
import os
66
import threading
7+
import warnings
78
import unittest
89
from concurrent import futures
910
from test import support
@@ -67,20 +68,22 @@ def submit(pool):
6768
workers.submit(tuple)
6869

6970
@support.requires_fork()
70-
@unittest.skipUnless(hasattr(os, 'register_at_fork'), 'need os.register_at_fork')
71-
@support.requires_resource('cpu')
71+
@unittest.skipUnless(hasattr(os, "register_at_fork"), "need os.register_at_fork")
72+
@support.requires_resource("cpu")
7273
def test_process_fork_from_a_threadpool(self):
7374
# bpo-43944: clear concurrent.futures.thread._threads_queues after fork,
7475
# otherwise child process will try to join parent thread
7576
def fork_process_and_return_exitcode():
76-
p = mp.get_context('fork').Process(target=lambda: 1)
77-
p.start()
77+
# Ignore the warning about fork with threads.
78+
with warnings.catch_warnings(category=DeprecationWarning, action="ignore"):
79+
p = mp.get_context("fork").Process(target=lambda: 1)
80+
p.start()
7881
p.join()
7982
return p.exitcode
80-
83+
8184
with futures.ThreadPoolExecutor(1) as pool:
8285
process_exitcode = pool.submit(fork_process_and_return_exitcode).result()
83-
86+
8487
self.assertEqual(process_exitcode, 0)
8588

8689
def test_executor_map_current_future_cancel(self):

0 commit comments

Comments
 (0)