Avoid stack-trace and DOS if event is not well formed

This commit is contained in:
nemunaire 2016-10-18 01:45:39 +02:00 committed by nemunaire
parent 4f1dcb8524
commit bdf8a69ff0

View File

@ -394,7 +394,13 @@ class Bot(threading.Thread):
self.event_timer.cancel() self.event_timer.cancel()
if len(self.events): if len(self.events):
try:
remaining = self.events[0].time_left.total_seconds() 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) 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 = threading.Timer(remaining if remaining > 0 else 0, self._end_event_timer)
self.event_timer.start() self.event_timer.start()