]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Add a brute-force workaround for the class of libcurl bugs that cause
authorBen Darnell <ben@bendarnell.com>
Thu, 5 Aug 2010 00:30:20 +0000 (17:30 -0700)
committerBen Darnell <ben@bendarnell.com>
Thu, 5 Aug 2010 00:30:20 +0000 (17:30 -0700)
file descriptors or timeouts to get silently dropped.  (the old
fdset/perform implementation of AsycnHTTPClient had a similar workaround).

tornado/httpclient.py

index 9151d00e32ba5666853af63234cb35b163763d1b..355ceed3e7f9b6b5be4c9d8ecf83226eed67a2b3 100644 (file)
@@ -143,6 +143,14 @@ class AsyncHTTPClient(object):
                 instance._socket_action = \
                     lambda fd, action: instance._multi.socket_all()
 
+            # libcurl has bugs that sometimes cause it to not report all
+            # relevant file descriptors and timeouts to TIMERFUNCTION/
+            # 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)
+            instance._force_timeout_callback.start()
+
             return instance
 
     def close(self):
@@ -152,6 +160,7 @@ class AsyncHTTPClient(object):
         on the AsyncHTTPClient after close().
         """
         del AsyncHTTPClient._ASYNC_CLIENTS[self.io_loop]
+        self._force_timeout_callback.stop()
         for curl in self._curls:
             curl.close()
         self._multi.close()