summaryrefslogtreecommitdiff
path: root/sphinx/util/parallel.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/util/parallel.py')
-rw-r--r--sphinx/util/parallel.py17
1 files changed, 15 insertions, 2 deletions
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():