]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Always advance _next_timeout in PeriodicCallback._schedule_next().
authorBen Darnell <ben@bendarnell.com>
Tue, 4 Oct 2011 15:54:38 +0000 (08:54 -0700)
committerBen Darnell <ben@bendarnell.com>
Tue, 4 Oct 2011 16:04:58 +0000 (09:04 -0700)
On fast machines (and platforms where time.time() has low resolution),
it's possible to make it through an IOLoop iteration with time.time()
unchanged, which would cause the callback to be run multiple times
regardless of the requested interval.

Closes #366.

tornado/ioloop.py

index f9a9f372eea5457f4437cbbbfbfe9e419c02f933..bcf5d521c86a911c89d535098bca960376d1c486 100644 (file)
@@ -477,7 +477,7 @@ class PeriodicCallback(object):
     def _schedule_next(self):
         if self._running:
             current_time = time.time()
-            while self._next_timeout < current_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)