From b809451be29d4c734045181098907c466e100249 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Tue, 18 Oct 2016 01:45:39 +0200 Subject: [PATCH] Avoid stack-trace and DOS if event is not well formed --- nemubot/bot.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nemubot/bot.py b/nemubot/bot.py index c8ede40..42f9aa7 100644 --- a/nemubot/bot.py +++ b/nemubot/bot.py @@ -394,7 +394,13 @@ class Bot(threading.Thread): self.event_timer.cancel() if len(self.events): - remaining = self.events[0].time_left.total_seconds() + try: + remaining = self.events[0].time_left.total_seconds() + except: + logger.exception("An error occurs during event time calculation:") + self.events.pop(0) + return self._update_event_timer() + logger.debug("Update timer: next event in %d seconds", remaining) self.event_timer = threading.Timer(remaining if remaining > 0 else 0, self._end_event_timer) self.event_timer.start()