diff --git a/SABnzbd.py b/SABnzbd.py index 48da667..74b2213 100755 --- a/SABnzbd.py +++ b/SABnzbd.py @@ -1431,9 +1431,13 @@ def main(): ### 3 sec polling tasks # Check for auto-restart request if cherrypy.engine.execv: - scheduler.stop() - sabnzbd.halt() - cherrypy.engine.exit() + if sabnzbd.SCHED_RESTART: + scheduler.abort() + sabnzbd.halt() + else: + scheduler.stop() + sabnzbd.halt() + cherrypy.engine.exit() sabnzbd.SABSTOP = True if sabnzbd.downloader.Downloader.do.paused: re_argv.append('-p') diff --git a/sabnzbd/__init__.py b/sabnzbd/__init__.py index 64a65ed..7ac1b83 100644 --- a/sabnzbd/__init__.py +++ b/sabnzbd/__init__.py @@ -124,6 +124,7 @@ RESTART_REQ = False OSX_ICON = 1 PAUSED_ALL = False OLD_QUEUE = False +SCHED_RESTART = False # Set when restarted through scheduler __INITIALIZED__ = False __SHUTTING_DOWN__ = False @@ -643,11 +644,11 @@ def shutdown_program(): def restart_program(): """ Restart program (used by scheduler) """ - logging.info("Performing sabnzbd restart") - sabnzbd.halt() - while __INITIALIZED__: - time.sleep(1.0) - cherrypy.engine.restart() + global SCHED_RESTART + logging.info("Scheduled restart request") + # Just set the stop flag, because stopping CherryPy from + # the scheduler is not reliable + cherrypy.engine.execv = SCHED_RESTART = True def change_queue_complete_action(action, new=True):