From 7aec8fc9b3e969eb7a345aefd689501035d967dd Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Tue, 2 Aug 2011 23:47:55 -0700 Subject: [PATCH] If a PeriodicCallback runs longer than its period, skip the missed callbacks instead of trying to run all the missed callbacks to catch up. --- tornado/ioloop.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tornado/ioloop.py b/tornado/ioloop.py index 7e7da905..7d31480a 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -461,7 +461,9 @@ class PeriodicCallback(object): def _schedule_next(self): if self._running: - self._next_timeout += self.callback_time / 1000.0 + current_time = time.time() + while self._next_timeout < current_time: + self._next_timeout += self.callback_time / 1000.0 self.io_loop.add_timeout(self._next_timeout, self._run)