diff options
| author | 2019-06-17 11:11:35 +0100 | |
|---|---|---|
| committer | 2019-06-17 11:11:35 +0100 | |
| commit | 9ea356bc49922305dba3bea007d35df669ec33f0 (patch) | |
| tree | 5ab2baeac02dcb4edb6c64b7667d89681bd677d8 /src | |
| parent | Add IRCBot.panic() - a nicer interface for killing the whole application (diff) | |
| signature | ||
Raise a BitBotPanic() exception in panic()
Diffstat (limited to 'src')
| -rw-r--r-- | src/IRCBot.py | 6 |
1 files changed, 6 insertions, 0 deletions
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) |
