File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -396,16 +396,12 @@ def stop_workers(self) -> None:
396
396
worker .wait_stopped (start_time )
397
397
398
398
def _get_result (self ) -> QueueOutput | None :
399
- if not any (worker .is_alive () for worker in self .workers ):
400
- # all worker threads are done: consume pending results
401
- try :
402
- return self .output .get (timeout = 0 )
403
- except queue .Empty :
404
- return None
405
-
406
399
use_faulthandler = (self .ns .timeout is not None )
407
400
timeout = PROGRESS_UPDATE
408
- while True :
401
+
402
+ # bpo-46205: check the status of workers every iteration to avoid
403
+ # waiting forever on an empty queue.
404
+ while any (worker .is_alive () for worker in self .workers ):
409
405
if use_faulthandler :
410
406
faulthandler .dump_traceback_later (MAIN_PROCESS_TIMEOUT ,
411
407
exit = True )
@@ -421,6 +417,12 @@ def _get_result(self) -> QueueOutput | None:
421
417
if running and not self .ns .pgo :
422
418
self .log ('running: %s' % ', ' .join (running ))
423
419
420
+ # all worker threads are done: consume pending results
421
+ try :
422
+ return self .output .get (timeout = 0 )
423
+ except queue .Empty :
424
+ return None
425
+
424
426
def display_result (self , mp_result : MultiprocessResult ) -> None :
425
427
result = mp_result .result
426
428
Original file line number Diff line number Diff line change
1
+ Fix hang in runtest_mp due to race condition
You can’t perform that action at this time.
0 commit comments