pop timer from dict when it expires
This commit is contained in:
parent
893bd3e70b
commit
8f7e1e6872
1 changed files with 6 additions and 2 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue