mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Add try catch around process kill
This commit is contained in:
parent
3711c94ffe
commit
ed60e55ffe
@ -9,6 +9,7 @@ import subprocess
|
|||||||
import html
|
import html
|
||||||
import tempfile
|
import tempfile
|
||||||
import psutil
|
import psutil
|
||||||
|
from psutil import NoSuchProcess
|
||||||
|
|
||||||
# TZLocal is set as a hidden import on win pipeline
|
# TZLocal is set as a hidden import on win pipeline
|
||||||
from tzlocal import get_localzone
|
from tzlocal import get_localzone
|
||||||
@ -670,8 +671,11 @@ class Server:
|
|||||||
|
|
||||||
def kill(self):
|
def kill(self):
|
||||||
logger.info(f"Terminating server {self.server_id} and all child processes")
|
logger.info(f"Terminating server {self.server_id} and all child processes")
|
||||||
|
try:
|
||||||
process = psutil.Process(self.process.pid)
|
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 every sub process...
|
||||||
for proc in process.children(recursive=True):
|
for proc in process.children(recursive=True):
|
||||||
# kill all the child processes
|
# kill all the child processes
|
||||||
|
Loading…
Reference in New Issue
Block a user