From c5e19a045d91b04c2796154a86b945adb784554e Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Tue, 4 Oct 2011 08:54:38 -0700 Subject: [PATCH] Always advance _next_timeout in PeriodicCallback._schedule_next(). 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tornado/ioloop.py b/tornado/ioloop.py index f9a9f372e..bcf5d521c 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -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) -- 2.47.2