@@ -116,14 +116,14 @@ def run_tests(critical_tests, other_tests, exclusive_tests):
116116 cancelled = False
117117 max_workers = 1 if "--not-parallel" in sys .argv else None
118118
119- max_tasks_per_child = None
119+ exc_args = {}
120120 if (
121121 "max_tasks_per_child"
122122 in inspect .signature (concurrent .futures .ProcessPoolExecutor ).parameters .keys ()
123123 ):
124124 # Limit to 1-to-1 processing to allow for timeout canceling at the
125125 # process level.
126- max_tasks_per_child = 1
126+ exc_args [ " max_tasks_per_child" ] = 1
127127
128128 def handler (sig , frame ):
129129 cancelled = True
@@ -139,14 +139,14 @@ def handler(sig, frame):
139139 start_ts = time .perf_counter ()
140140
141141 try :
142- executor = concurrent . futures . ProcessPoolExecutor (
143- max_workers = max_workers ,
144- max_tasks_per_child = max_tasks_per_child )
145- execute_tests (executor , all_tests , max_test_name_len )
146- executor = concurrent . futures . ProcessPoolExecutor (
147- max_workers = 1 ,
148- max_tasks_per_child = max_tasks_per_child )
149- execute_tests (executor , exclusive_tests , max_test_name_len )
142+ if not cancelled :
143+ executor = concurrent . futures . ProcessPoolExecutor (
144+ max_workers = max_workers , ** exc_args )
145+ execute_tests (executor , all_tests , max_test_name_len )
146+ if not cancelled :
147+ executor = concurrent . futures . ProcessPoolExecutor (
148+ max_workers = 1 , ** exc_args )
149+ execute_tests (executor , exclusive_tests , max_test_name_len )
150150 except concurrent .futures .process .BrokenProcessPool :
151151 # It could be us who broke the pool by terminating its threads
152152 if not cancelled :
0 commit comments