From 3c84741e8abc25a2fbe99d9c7eae81e23e195656 Mon Sep 17 00:00:00 2001 From: ArabCoders Date: Fri, 29 Mar 2024 00:42:38 +0300 Subject: [PATCH] terminate if process still alive after kill --- app/Download.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Download.py b/app/Download.py index b8610622..c8bcaeaa 100644 --- a/app/Download.py +++ b/app/Download.py @@ -193,7 +193,7 @@ class Download: if not os.path.exists(self.tempPath): os.makedirs(self.tempPath, exist_ok=True) - self.proc = multiprocessing.Process(target=self._download) + self.proc = multiprocessing.Process(name=f"download-{self.id}", target=self._download) self.proc.start() self.info.status = 'preparing' @@ -244,6 +244,8 @@ class Download: try: LOG.info(f"Killing download process: '{self.proc.ident}'.") self.proc.kill() + if self.proc.is_alive(): + self.proc.terminate() return True except Exception as e: LOG.error(f"Failed to kill process: '{self.proc.ident}'. {e}")