Stop scheduler also on restart calibre-web

This commit is contained in:
Ozzie Isaacs 2023-01-29 09:54:07 +01:00
parent 9701a97a57
commit c4e4acfc26
2 changed files with 8 additions and 2 deletions

View File

@ -22,6 +22,7 @@ import errno
import signal import signal
import socket import socket
import subprocess # nosec import subprocess # nosec
from .services.background_scheduler import BackgroundScheduler
try: try:
from gevent.pywsgi import WSGIServer from gevent.pywsgi import WSGIServer
@ -265,6 +266,12 @@ class WebServer(object):
subprocess.call(args, close_fds=True) # nosec subprocess.call(args, close_fds=True) # nosec
return True return True
@staticmethod
def shutdown_scheduler():
scheduler = BackgroundScheduler()
if scheduler:
scheduler.scheduler.shutdown()
def _killServer(self, __, ___): def _killServer(self, __, ___):
self.stop() self.stop()
@ -273,6 +280,7 @@ class WebServer(object):
updater_thread.stop() updater_thread.stop()
log.info("webserver stop (restart=%s)", restart) log.info("webserver stop (restart=%s)", restart)
self.shutdown_scheduler()
self.restart = restart self.restart = restart
if self.wsgiserver: if self.wsgiserver:
if _GEVENT: if _GEVENT:

View File

@ -45,8 +45,6 @@ class BackgroundScheduler:
cls.scheduler = BScheduler() cls.scheduler = BScheduler()
cls.scheduler.start() cls.scheduler.start()
atexit.register(lambda: cls.scheduler.shutdown())
return cls._instance return cls._instance
def schedule(self, func, trigger, name=None): def schedule(self, func, trigger, name=None):