From: Ben Darnell Date: Thu, 21 Feb 2013 03:03:28 +0000 (-0500) Subject: Clean up more timeouts when shutting down HTTP clients or finishing tests. X-Git-Tag: v3.0.0~100 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4167f97880a35ef5b32433455e804fa1a24e38b;p=thirdparty%2Ftornado.git Clean up more timeouts when shutting down HTTP clients or finishing tests. --- diff --git a/tornado/curl_httpclient.py b/tornado/curl_httpclient.py index 028c80584..f46ea7b87 100644 --- a/tornado/curl_httpclient.py +++ b/tornado/curl_httpclient.py @@ -81,6 +81,8 @@ class CurlAsyncHTTPClient(AsyncHTTPClient): def close(self): self._force_timeout_callback.stop() + if self._timeout is not None: + self.io_loop.remove_timeout(self._timeout) for curl in self._curls: curl.close() self._multi.close() diff --git a/tornado/test/httpclient_test.py b/tornado/test/httpclient_test.py index 039720e2d..cfba97929 100644 --- a/tornado/test/httpclient_test.py +++ b/tornado/test/httpclient_test.py @@ -285,6 +285,7 @@ Transfer-Encoding: chunked client.fetch(self.get_url('/user_agent'), callback=self.stop) response = self.wait() self.assertEqual(response.body, b'TestDefaultUserAgent') + client.close() def test_304_with_content_length(self): # According to the spec 304 responses SHOULD NOT include diff --git a/tornado/testing.py b/tornado/testing.py index de6e5b4fb..30fe4e29c 100644 --- a/tornado/testing.py +++ b/tornado/testing.py @@ -223,8 +223,6 @@ class AsyncTestCase(unittest.TestCase): except Exception: self.__failure = sys.exc_info() self.stop() - if self.__timeout is not None: - self.io_loop.remove_timeout(self.__timeout) self.__timeout = self.io_loop.add_timeout(self.io_loop.time() + timeout, timeout_func) while True: self.__running = True @@ -232,6 +230,9 @@ class AsyncTestCase(unittest.TestCase): if (self.__failure is not None or condition is None or condition()): break + if self.__timeout is not None: + self.io_loop.remove_timeout(self.__timeout) + self.__timeout = None assert self.__stopped self.__stopped = False self.__rethrow()