]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Check for the existence of callbacks after running all timeouts
authorBen Darnell <ben@bendarnell.com>
Thu, 30 Jun 2011 02:41:02 +0000 (19:41 -0700)
committerBen Darnell <ben@bendarnell.com>
Thu, 30 Jun 2011 02:41:02 +0000 (19:41 -0700)
tornado/ioloop.py

index 45a8499791a0e7287ab4d28676a3a448e07bd380..78c41d75e329eeadbc70ffde684b40bd0c387e74 100644 (file)
@@ -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