pop timer from dict when it expires

This commit is contained in:
Romain Bignon 2010-07-13 15:09:50 +02:00
commit 8f7e1e6872

View file

@ -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)