diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-03-06 17:30:00 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-06 17:30:00 +0900 |
commit | ad10c62d74650e5779cdf64e6682595d8be87387 (patch) | |
tree | 467a2652427d9e267a8aa835afd9056d67434142 | |
parent | 99d97c65d50e34f67a090c9e9ed9df8f9d9941a7 (diff) | |
parent | ec6ab7243da2f311e11ed3505171ec3001a1704b (diff) | |
download | sphinx-git-ad10c62d74650e5779cdf64e6682595d8be87387.tar.gz |
Merge pull request #8957 from tk0miya/8952_hangup_on_parallel_build
Fix #8952: Exceptions raised in a Directive cause parallel builds to hang
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | sphinx/util/parallel.py | 17 |
2 files changed, 17 insertions, 2 deletions
@@ -16,6 +16,8 @@ Features added Bugs fixed ---------- +* #8952: Exceptions raised in a Directive cause parallel builds to hang + Testing -------- diff --git a/sphinx/util/parallel.py b/sphinx/util/parallel.py index ab27a5128..ed73ee4d6 100644 --- a/sphinx/util/parallel.py +++ b/sphinx/util/parallel.py @@ -103,8 +103,21 @@ class ParallelTasks: 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(): |