From fc66f9f3724cb4ad3132db6890837f0f62cef5ae Mon Sep 17 00:00:00 2001 From: derrod Date: Thu, 30 Dec 2021 14:34:02 +0100 Subject: [PATCH] [downloader/mp] Also kill workers on interrupt if they don't exit themselves --- legendary/downloader/mp/manager.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/legendary/downloader/mp/manager.py b/legendary/downloader/mp/manager.py index 869e19f..ad3c07c 100644 --- a/legendary/downloader/mp/manager.py +++ b/legendary/downloader/mp/manager.py @@ -585,6 +585,12 @@ class DLManager(Process): if t.is_alive(): self.log.warning(f'Thread did not terminate! {repr(t)}') + # forcibly kill DL workers that are not actually dead yet + for child in self.children: + child.join(timeout=5.0) + if child.exitcode is None: + child.terminate() + # clean up all the queues, otherwise this process won't terminate properly for name, q in zip(('Download jobs', 'Writer jobs', 'Download results', 'Writer results'), (self.dl_worker_queue, self.writer_queue, self.dl_result_q, self.writer_result_q)):