mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
Move control.tried_shutdown to world.shutting_down
This commit is contained in:
parent
19bd3ec0b2
commit
82a7b914b6
@ -26,7 +26,6 @@ except ImportError:
|
||||
|
||||
from . import world, utils, structures, conf, __version__
|
||||
from .log import *
|
||||
from .coremods import control
|
||||
from .utils import ProtocolError # Compatibility with PyLink 1.x
|
||||
|
||||
### Internal classes (users, servers, channels)
|
||||
@ -1265,7 +1264,7 @@ class IRCNetwork(PyLinkNetworkCoreWithUtils):
|
||||
def _log_connection_error(self, *args, **kwargs):
|
||||
# Log connection errors to ERROR unless were shutting down (in which case,
|
||||
# the given text goes to DEBUG).
|
||||
if self._aborted.is_set() or control.tried_shutdown:
|
||||
if self._aborted.is_set() or world.shutting_down.is_set():
|
||||
log.debug(*args, **kwargs)
|
||||
else:
|
||||
log.error(*args, **kwargs)
|
||||
|
@ -11,8 +11,6 @@ from pylinkirc import world, utils, conf # Do not import classes, it'll import
|
||||
from pylinkirc.log import log, makeFileLogger, stopFileLoggers, getConsoleLogLevel
|
||||
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.
|
||||
@ -57,12 +55,11 @@ atexit.register(_kill_plugins)
|
||||
|
||||
def shutdown(irc=None):
|
||||
"""Shuts down the Pylink daemon."""
|
||||
global tried_shutdown
|
||||
if tried_shutdown: # We froze on shutdown last time, so immediately abort.
|
||||
if world.shutting_down.is_set(): # We froze on shutdown last time, so immediately abort.
|
||||
_print_remaining_threads()
|
||||
raise KeyboardInterrupt("Forcing shutdown.")
|
||||
|
||||
tried_shutdown = True
|
||||
world.shutting_down.set()
|
||||
|
||||
# HACK: run the _kill_plugins trigger with the current IRC object. XXX: We should really consider removing this
|
||||
# argument, since no plugins actually use it to do anything.
|
||||
|
5
world.py
5
world.py
@ -22,8 +22,13 @@ exttarget_handlers = {}
|
||||
|
||||
# Trigger to be set when all IRC objects are initially created.
|
||||
started = threading.Event()
|
||||
|
||||
# Global daemon starting time.
|
||||
start_ts = time.time()
|
||||
|
||||
# Trigger to set on shutdown.
|
||||
shutting_down = threading.Event()
|
||||
|
||||
# Source address.
|
||||
source = "https://github.com/GLolol/PyLink" # CHANGE THIS IF YOU'RE FORKING!!
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user