File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Lib/test/test_concurrent_futures Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,25 @@ def submit(pool):
66
66
with futures .ProcessPoolExecutor (1 , mp_context = mp .get_context ('fork' )) as workers :
67
67
workers .submit (tuple )
68
68
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
+
69
88
def test_executor_map_current_future_cancel (self ):
70
89
stop_event = threading .Event ()
71
90
log = []
You can’t perform that action at this time.
0 commit comments