From: Ben Darnell Date: Mon, 9 Aug 2010 21:01:48 +0000 (-0700) Subject: The periodic call to multi_socket_all needs to be followed by X-Git-Tag: v1.1.0~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fef1129b1668853fd854345a3b3ba3fcfd306ad0;p=thirdparty%2Ftornado.git The periodic call to multi_socket_all needs to be followed by _finish_pending_request or else those requests won't be finished until after the next one is started. --- diff --git a/tornado/httpclient.py b/tornado/httpclient.py index 1552875b7..1e8bd976a 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -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.