def add_timer(self, callback, when, interval, ident=None):
''' Add timer to the queue.
:param callback: Arbitrary callable object.
:type callback: ``callable object``
:param when: The first expiration time, seconds since epoch.
:type when: ``integer``
:param interval: Timer interval, if equals 0, one time timer, otherwise
the timer will be periodically executed
:type interval: ``integer``
:param ident: (optional) Timer identity.
:type ident: ``integer``
:returns: A timer object which should not be manipulated directly by
clients. Used to delete/update the timer
'''
with self._lock:
timer = self._timers.add_timer(callback, when, interval, ident)
self._wakeup()
return timer
评论列表
文章目录