Use `finally` to terminate parallel processes (#10952)

This commit is contained in:
Philip Meier 2023-01-02 10:22:45 +01:00 committed by GitHub
parent cc8f697a9b
commit 6037ec3b9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -98,10 +98,9 @@ class ParallelTasks:
while self._pworking:
if not self._join_one():
time.sleep(0.02)
except Exception:
finally:
# shutdown other child processes on failure
self.terminate()
raise
def terminate(self) -> None:
for tid in list(self._precvs):