]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
The periodic call to multi_socket_all needs to be followed by
authorBen Darnell <ben@bendarnell.com>
Mon, 9 Aug 2010 21:01:48 +0000 (14:01 -0700)
committerBen Darnell <ben@bendarnell.com>
Mon, 9 Aug 2010 21:01:48 +0000 (14:01 -0700)
 _finish_pending_request or else those requests won't be finished until
after the next one is started.

tornado/httpclient.py

index 1552875b78b23b7305146763a6e248798ccd1a53..1e8bd976a9334747ab59feb23f3d7e7d53057c46 100644 (file)
@@ -148,7 +148,7 @@ class AsyncHTTPClient(object):
             # SOCKETFUNCTION.  Mitigate the effects of such bugs by
             # forcing a periodic scan of all active requests.
             instance._force_timeout_callback = ioloop.PeriodicCallback(
-                instance._multi.socket_all, 1000, io_loop=io_loop)
+                instance._handle_force_timeout, 1000, io_loop=io_loop)
             instance._force_timeout_callback.start()
 
             return instance
@@ -257,6 +257,20 @@ class AsyncHTTPClient(object):
         if new_timeout != -1:
             self._set_timeout(new_timeout)
 
+    def _handle_force_timeout(self):
+        """Called by IOLoop periodically to ask libcurl to process any
+        events it may have forgotten about.
+        """
+        with stack_context.NullContext():
+            while True:
+                try:
+                    ret, num_handles = self._multi.socket_all()
+                except pycurl.error, e:
+                    ret = e[0]
+                if ret != pycurl.E_CALL_MULTI_PERFORM:
+                    break
+            self._finish_pending_requests()
+
     def _finish_pending_requests(self):
         """Process any requests that were completed by the last
         call to multi.socket_action.