From 43e02a2d88d67fdc8da532c60b13125af11590e4 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Mon, 19 Apr 2010 11:03:06 -0700 Subject: [PATCH] Add a closed flag to AsyncHTTPClient so that a scheduled perform callback won't cause an exception after the client is closed. --- tornado/httpclient.py | 5 +++++ 1 file changed, 5 insertions(+) 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() -- 2.47.2