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 @@ -392,16 +392,12 @@ def stop_workers(self) -> None:
392
392
worker .wait_stopped (start_time )
393
393
394
394
def _get_result (self ) -> QueueOutput | None :
395
- if not any (worker .is_alive () for worker in self .workers ):
396
- # all worker threads are done: consume pending results
397
- try :
398
- return self .output .get (timeout = 0 )
399
- except queue .Empty :
400
- return None
401
-
402
395
use_faulthandler = (self .ns .timeout is not None )
403
396
timeout = PROGRESS_UPDATE
404
- while True :
397
+
398
+ # bpo-46205: check the status of workers every iteration to avoid
399
+ # waiting forever on an empty queue.
400
+ while any (worker .is_alive () for worker in self .workers ):
405
401
if use_faulthandler :
406
402
faulthandler .dump_traceback_later (MAIN_PROCESS_TIMEOUT ,
407
403
exit = True )
@@ -417,6 +413,12 @@ def _get_result(self) -> QueueOutput | None:
417
413
if running and not self .ns .pgo :
418
414
self .log ('running: %s' % ', ' .join (running ))
419
415
416
+ # all worker threads are done: consume pending results
417
+ try :
418
+ return self .output .get (timeout = 0 )
419
+ except queue .Empty :
420
+ return None
421
+
420
422
def display_result (self , mp_result : MultiprocessResult ) -> None :
421
423
result = mp_result .result
422
424
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