]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
If a PeriodicCallback runs longer than its period, skip the missed callbacks
authorBen Darnell <ben@bendarnell.com>
Wed, 3 Aug 2011 06:47:55 +0000 (23:47 -0700)
committerBen Darnell <ben@bendarnell.com>
Wed, 3 Aug 2011 06:47:55 +0000 (23:47 -0700)
instead of trying to run all the missed callbacks to catch up.

tornado/ioloop.py

index 7e7da905d58eeab645cfbf47749dd639d156e582..7d31480a017a7d1e6f12889373787247e92ff1ad 100644 (file)
@@ -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)