From: Ben Darnell Date: Thu, 5 Aug 2010 00:30:20 +0000 (-0700) Subject: Add a brute-force workaround for the class of libcurl bugs that cause X-Git-Tag: v1.1.0~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8995f5a0f93717e27e01fd1de2e7ab8f54782276;p=thirdparty%2Ftornado.git Add a brute-force workaround for the class of libcurl bugs that cause file descriptors or timeouts to get silently dropped. (the old fdset/perform implementation of AsycnHTTPClient had a similar workaround). --- diff --git a/tornado/httpclient.py b/tornado/httpclient.py index 9151d00e3..355ceed3e 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -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()