Raise a BitBotPanic() exception in panic()

This commit is contained in:
jesopo 2019-06-17 11:11:35 +01:00
parent f8fa529ca5
commit 9ea356bc49

View file

@ -19,6 +19,9 @@ class TriggerEvent(object):
self.type = type self.type = type
self.callback = callback self.callback = callback
class BitBotPanic(Exception):
pass
class Bot(object): class Bot(object):
def __init__(self, directory, args, cache, config, database, events, def __init__(self, directory, args, cache, config, database, events,
exports, log, modules, timers): exports, log, modules, timers):
@ -113,6 +116,7 @@ class Bot(object):
callback = _raise callback = _raise
self._event_queue.put(TriggerEvent(TriggerEventType.Kill, callback)) self._event_queue.put(TriggerEvent(TriggerEventType.Kill, callback))
raise BitBotPanic()
def load_modules(self, safe: bool=False def load_modules(self, safe: bool=False
) -> typing.Tuple[typing.List[str], typing.List[str]]: ) -> 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]): def _loop_catch(self, name: str, loop: typing.Callable[[], None]):
try: try:
loop() loop()
except BitBotPanic:
return
except Exception as e: except Exception as e:
self.panic("Exception on '%s' thread" % name) self.panic("Exception on '%s' thread" % name)