From: Ben Darnell Date: Mon, 19 Apr 2010 18:03:06 +0000 (-0700) Subject: Add a closed flag to AsyncHTTPClient so that a scheduled perform callback X-Git-Tag: v1.0.0~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43e02a2d88d67fdc8da532c60b13125af11590e4;p=thirdparty%2Ftornado.git Add a closed flag to AsyncHTTPClient so that a scheduled perform callback won't cause an exception after the client is closed. --- diff --git a/tornado/httpclient.py b/tornado/httpclient.py index 2c9155eb9..c232d832e 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -122,6 +122,7 @@ class AsyncHTTPClient(object): instance._events = {} instance._added_perform_callback = False instance._timeout = None + instance._closed = False cls._ASYNC_CLIENTS[io_loop] = instance return instance @@ -135,6 +136,7 @@ class AsyncHTTPClient(object): for curl in self._curls: curl.close() self._multi.close() + self._closed = True def fetch(self, request, callback, **kwargs): """Executes an HTTPRequest, calling callback with an HTTPResponse. @@ -165,6 +167,9 @@ class AsyncHTTPClient(object): def _perform(self): self._added_perform_callback = False + if self._closed: + return + while True: while True: ret, num_handles = self._multi.perform()