From: Ben Darnell Date: Thu, 18 Mar 2010 20:27:49 +0000 (-0700) Subject: Add a close method to AsyncHTTPClient. X-Git-Tag: v1.0.0~73^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70fb42d6a0b5e4fa2eed4d3aa4c795b957798e19;p=thirdparty%2Ftornado.git Add a close method to AsyncHTTPClient. --- diff --git a/tornado/httpclient.py b/tornado/httpclient.py index e65ed40ec..a87384542 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -124,6 +124,17 @@ class AsyncHTTPClient(object): cls._ASYNC_CLIENTS[io_loop] = instance return instance + def close(self): + """Destroys this http client, freeing any file descriptors used. + Not needed in normal use, but may be helpful in unittests that + create and destroy http clients. No other methods may be called + on the AsyncHTTPClient after close(). + """ + del AsyncHTTPClient._ASYNC_CLIENTS[self.io_loop] + for curl in self._curls: + curl.close() + self._multi.close() + def fetch(self, request, callback, **kwargs): """Executes an HTTPRequest, calling callback with an HTTPResponse.