From: Ben Darnell Date: Thu, 30 Jun 2011 02:41:02 +0000 (-0700) Subject: Check for the existence of callbacks after running all timeouts X-Git-Tag: v2.1.0~137 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fd7f1a5b334bd794d31fcbf068aaec98483c911;p=thirdparty%2Ftornado.git Check for the existence of callbacks after running all timeouts --- diff --git a/tornado/ioloop.py b/tornado/ioloop.py index 45a849979..78c41d75e 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -257,9 +257,6 @@ class IOLoop(object): for callback in callbacks: self._run_callback(callback) - if self._callbacks: - poll_timeout = 0.0 - if self._timeouts: now = time.time() while self._timeouts: @@ -274,6 +271,11 @@ class IOLoop(object): poll_timeout = min(milliseconds, poll_timeout) break + if self._callbacks: + # If any callbacks or timeouts called add_callback, + # we don't want to wait in poll() before we run them. + poll_timeout = 0.0 + if not self._running: break