Skip to content

Commit

Permalink
Fix #8952: Exceptions raised in a Directive cause parallel builds to …
Browse files Browse the repository at this point in the history
…hang

Do shutdown explicitly when failure on the subprocess.
  • Loading branch information
tk0miya committed Mar 4, 2021
1 parent 99d97c6 commit ec6ab72
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES
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
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

0 comments on commit ec6ab72

Please sign in to comment.