def runq(cls):
"""
Run the timer queue: for each timer whose call time has passed,
pull the timer off the queue and call its handler() method.
Comparisions are made against time at which this function was
called, so that even if new events keep getting scheduled, we'll
return to the I/O loop reasonably quickly.
"""
now = rpki.sundial.now()
while timer_queue and now >= timer_queue[0].when:
t = timer_queue.pop(0)
if cls.run_debug:
logger.debug("Running %r", t)
try:
if t.handler is not None:
t.handler()
else:
logger.warning("Timer %r expired with no handler set", t)
except (ExitNow, SystemExit):
raise
except Exception, e:
if t.errback is not None:
t.errback(e)
else:
logger.exception("Unhandled exception from timer %r", t)
评论列表
文章目录