From 6e06b616fd568d2e5a26d1bc38e96abb66f5b22b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9munaire?= Date: Thu, 16 Aug 2012 04:53:46 +0200 Subject: [PATCH] Stop the event timer before quit --- bot.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bot.py b/bot.py index 5eb8d85..01e3130 100644 --- a/bot.py +++ b/bot.py @@ -40,6 +40,7 @@ class Bot: def add_event(self, evt): + """Register an event""" # Add the event in place t = evt.current i = 0 @@ -51,6 +52,7 @@ class Bot: self.update_timer() def update_timer(self): + """Relaunch the timer to end with the closest event""" # Reset the timer if this is the first item if self.event_timer is not None: self.event_timer.cancel() @@ -68,6 +70,7 @@ class Bot: def end_timer(self): + """Function called at the end of the timer""" #print ("end timer") while len(self.events)>0 and datetime.now() >= self.events[0].current: #print ("end timer: while") @@ -130,6 +133,10 @@ class Bot: def quit(self, verb=False): """Save and unload modules and disconnect servers""" + if self.event_timer is not None: + if verb: print ("Stop the event timer...") + self.event_timer.cancel() + if verb: print ("Save and unload all modules...") k = list(self.modules.keys()) for mod in k: