From 9ea356bc49922305dba3bea007d35df669ec33f0 Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 17 Jun 2019 11:11:35 +0100 Subject: [PATCH] Raise a BitBotPanic() exception in panic() --- src/IRCBot.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/IRCBot.py b/src/IRCBot.py index 83f353ca..052aa346 100644 --- a/src/IRCBot.py +++ b/src/IRCBot.py @@ -19,6 +19,9 @@ class TriggerEvent(object): self.type = type self.callback = callback +class BitBotPanic(Exception): + pass + class Bot(object): def __init__(self, directory, args, cache, config, database, events, exports, log, modules, timers): @@ -113,6 +116,7 @@ class Bot(object): callback = _raise self._event_queue.put(TriggerEvent(TriggerEventType.Kill, callback)) + raise BitBotPanic() def load_modules(self, safe: bool=False ) -> typing.Tuple[typing.List[str], typing.List[str]]: @@ -288,6 +292,8 @@ class Bot(object): def _loop_catch(self, name: str, loop: typing.Callable[[], None]): try: loop() + except BitBotPanic: + return except Exception as e: self.panic("Exception on '%s' thread" % name)