Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.9] bpo-46205: exit if no workers are alive in runtest_mp (GH-30470) #30524

Merged
merged 1 commit into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions Lib/test/libregrtest/runtest_mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,16 +396,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)
Expand All @@ -421,6 +417,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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix hang in runtest_mp due to race condition