From 6ad979a5eb63f7aca902faba5249ce8086735049 Mon Sep 17 00:00:00 2001 From: nemunaire Date: Fri, 22 Jan 2016 19:52:21 +0100 Subject: [PATCH] Fix event/timer issue if very close to 0 --- nemubot/bot.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/nemubot/bot.py b/nemubot/bot.py index be1d88a..a874e7b 100644 --- a/nemubot/bot.py +++ b/nemubot/bot.py @@ -380,11 +380,9 @@ class Bot(threading.Thread): self.event_timer.cancel() if len(self.events): - logger.debug("Update timer: next event in %d seconds", - self.events[0].time_left.seconds) - self.event_timer = threading.Timer( - self.events[0].time_left.seconds + self.events[0].time_left.microseconds / 1000000 if datetime.now(timezone.utc) < self.events[0].current else 0, - self._end_event_timer) + remaining = self.events[0].time_left.seconds + self.events[0].time_left.microseconds / 1000000 + 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() else: