From 40bcc9d68004023b09b84a37e637d3410d5322ad Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 19 Aug 2012 20:59:52 +0000 Subject: Tweak timer.runq() to be a bit more even-handed in how we prioritize I/O versus timers. svn path=/branches/tk274/; revision=4644 --- rpkid/rpki/async.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'rpkid/rpki/async.py') diff --git a/rpkid/rpki/async.py b/rpkid/rpki/async.py index ecea3bbd..f4786ebf 100644 --- a/rpkid/rpki/async.py +++ b/rpkid/rpki/async.py @@ -216,8 +216,13 @@ class timer(object): """ 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. """ - if timer_queue and rpki.sundial.now() >= timer_queue[0].when: + now = rpki.sundial.now() + while timer_queue and now >= timer_queue[0].when: t = timer_queue.pop(0) if cls.run_debug: rpki.log.debug("Running %r" % t) -- cgit v1.2.3