File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
Lib/test/test_concurrent_futures Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change 4
4
import multiprocessing .util
5
5
import os
6
6
import threading
7
+ import warnings
7
8
import unittest
8
9
from concurrent import futures
9
10
from test import support
@@ -67,20 +68,22 @@ def submit(pool):
67
68
workers .submit (tuple )
68
69
69
70
@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" )
72
73
def test_process_fork_from_a_threadpool (self ):
73
74
# bpo-43944: clear concurrent.futures.thread._threads_queues after fork,
74
75
# otherwise child process will try to join parent thread
75
76
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 ()
78
81
p .join ()
79
82
return p .exitcode
80
-
83
+
81
84
with futures .ThreadPoolExecutor (1 ) as pool :
82
85
process_exitcode = pool .submit (fork_process_and_return_exitcode ).result ()
83
-
86
+
84
87
self .assertEqual (process_exitcode , 0 )
85
88
86
89
def test_executor_map_current_future_cancel (self ):
You can’t perform that action at this time.
0 commit comments