From 8f7e1e68724243b1a3c966013f4b80bb03ec45a5 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Tue, 13 Jul 2010 15:09:50 +0200 Subject: [PATCH] pop timer from dict when it expires --- weboob/core/scheduler.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/weboob/core/scheduler.py b/weboob/core/scheduler.py index b4333e7c..9dff6011 100644 --- a/weboob/core/scheduler.py +++ b/weboob/core/scheduler.py @@ -48,11 +48,15 @@ class Scheduler(IScheduler): self.count += 1 logging.debug('function "%s" will be called in %s seconds' % (function.__name__, interval)) - timer = Timer(interval, function, args) - timer.start() + timer = Timer(interval, self._callback, (self.count, function, args)) self.queue[self.count] = timer + timer.start() return self.count + def _callback(self, count, function, args): + self.queue.pop(count) + return function(*args) + def repeat(self, interval, function, *args): return self._repeat(True, interval, function, *args)