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

Fix #8952: Exceptions raised in a Directive cause parallel builds to hang #8957

Merged
merged 1 commit into from
Mar 6, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Features added
Bugs fixed
----------

* #8952: Exceptions raised in a Directive cause parallel builds to hang

Testing
--------

Expand Down
17 changes: 15 additions & 2 deletions sphinx/util/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,21 @@ def add_task(self, task_func: Callable, arg: Any = None, result_func: Callable =
self._join_one()

def join(self) -> None:
while self._pworking:
self._join_one()
try:
while self._pworking:
self._join_one()
except Exception:
# shutdown other child processes on failure
self.terminate()
raise

def terminate(self) -> None:
for tid in list(self._precvs):
self._procs[tid].terminate()
self._result_funcs.pop(tid)
self._procs.pop(tid)
self._precvs.pop(tid)
self._pworking -= 1

def _join_one(self) -> None:
for tid, pipe in self._precvs.items():
Expand Down