mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
bpo-46205: exit if no workers are alive in runtest_mp (GH-30470)
(cherry picked from commit e13cdca0f5)
Co-authored-by: Sam Gross <colesbury@gmail.com>
This commit is contained in:
parent
2e6798f352
commit
e0ec08dc49
2 changed files with 11 additions and 8 deletions
|
|
@ -395,16 +395,12 @@ def stop_workers(self) -> None:
|
|||
worker.wait_stopped(start_time)
|
||||
|
||||
def _get_result(self) -> QueueOutput | None:
|
||||
if not any(worker.is_alive() for worker in self.workers):
|
||||
# all worker threads are done: consume pending results
|
||||
try:
|
||||
return self.output.get(timeout=0)
|
||||
except queue.Empty:
|
||||
return None
|
||||
|
||||
use_faulthandler = (self.ns.timeout is not None)
|
||||
timeout = PROGRESS_UPDATE
|
||||
while True:
|
||||
|
||||
# bpo-46205: check the status of workers every iteration to avoid
|
||||
# waiting forever on an empty queue.
|
||||
while any(worker.is_alive() for worker in self.workers):
|
||||
if use_faulthandler:
|
||||
faulthandler.dump_traceback_later(MAIN_PROCESS_TIMEOUT,
|
||||
exit=True)
|
||||
|
|
@ -420,6 +416,12 @@ def _get_result(self) -> QueueOutput | None:
|
|||
if running and not self.ns.pgo:
|
||||
self.log('running: %s' % ', '.join(running))
|
||||
|
||||
# all worker threads are done: consume pending results
|
||||
try:
|
||||
return self.output.get(timeout=0)
|
||||
except queue.Empty:
|
||||
return None
|
||||
|
||||
def display_result(self, mp_result: MultiprocessResult) -> None:
|
||||
result = mp_result.result
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Fix hang in runtest_mp due to race condition
|
||||
Loading…
Add table
Add a link
Reference in a new issue