From ed60e55ffea1a3b04bcd511b0bdafeb2c480bae4 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 12 Apr 2022 21:52:53 -0400 Subject: [PATCH] Add try catch around process kill --- app/classes/shared/server.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index a2cca09e..772ab969 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -9,6 +9,7 @@ import subprocess import html import tempfile import psutil +from psutil import NoSuchProcess # TZLocal is set as a hidden import on win pipeline from tzlocal import get_localzone @@ -670,8 +671,11 @@ class Server: def kill(self): logger.info(f"Terminating server {self.server_id} and all child processes") - process = psutil.Process(self.process.pid) - + try: + process = psutil.Process(self.process.pid) + except NoSuchProcess: + logger.info(f"Cannot kill {self.process.pid} as we cannot find that pid.") + return # for every sub process... for proc in process.children(recursive=True): # kill all the child processes