From a3f122fee4958540fd88acceec57aaf27dd18461 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 18 Feb 2017 12:19:42 -0800 Subject: [PATCH] control: try a more stable force-shutdown routine --- coremods/control.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/coremods/control.py b/coremods/control.py index 92ed19a..d1f8096 100644 --- a/coremods/control.py +++ b/coremods/control.py @@ -4,11 +4,14 @@ control.py - Implements SHUTDOWN and REHASH functionality. import signal import os import threading +import sys from pylinkirc import world, utils, conf, classes from pylinkirc.log import log, makeFileLogger, stopFileLoggers, stdoutLogLevel from . import permissions +tried_shutdown = False + def remove_network(ircobj): """Removes a network object from the pool.""" # Disable autoconnect first by setting the delay negative. @@ -18,6 +21,12 @@ def remove_network(ircobj): def _shutdown(irc=None): """Shuts down the Pylink daemon.""" + global tried_shutdown + if tried_shutdown: # We froze on shutdown last time, so immediately abort. + sys.exit() + + tried_shutdown = True + for name, plugin in world.plugins.items(): # Before closing connections, tell all plugins to shutdown cleanly first. if hasattr(plugin, 'die'):