Fix error when stats job does not exist on kill

This commit is contained in:
Andrew 2022-06-10 18:29:47 -04:00
parent 92eeefb4e8
commit 4a15a2331e

View File

@ -14,6 +14,7 @@ import tempfile
# TZLocal is set as a hidden import on win pipeline
from tzlocal import get_localzone
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.jobstores.base import JobLookupError
from app.classes.minecraft.stats import Stats
from app.classes.minecraft.mc_ping import ping, ping_bedrock
@ -687,7 +688,11 @@ class ServerInstance:
proc.kill()
# kill the main process we are after
logger.info("Sending SIGKILL to parent")
self.server_scheduler.remove_job("stats_" + str(self.server_id))
try:
self.server_scheduler.remove_job("stats_" + str(self.server_id))
except JobLookupError as e:
logger.error(f"Could not remove job with id stats_{self.server_id} due"+
f" to error: {e}")
self.process.kill()
def get_start_time(self):