]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Clean up more timeouts when shutting down HTTP clients or finishing tests.
authorBen Darnell <ben@bendarnell.com>
Thu, 21 Feb 2013 03:03:28 +0000 (22:03 -0500)
committerBen Darnell <ben@bendarnell.com>
Thu, 21 Feb 2013 03:03:28 +0000 (22:03 -0500)
tornado/curl_httpclient.py
tornado/test/httpclient_test.py
tornado/testing.py

index 028c80584e52cc61d9ccfe9f9990493de423b7e7..f46ea7b870afeac3a69ad42a435c1228da290a49 100644 (file)
@@ -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()
index 039720e2d2a1f4a8c8ed7616c396a1558b5d81fc..cfba97929ecdf76701ea12fb98304f531715b6ff 100644 (file)
@@ -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
index de6e5b4fb85cda73733d5fdfa6594cb602129012..30fe4e29cf6896bf368dd861d3c42ee85ad13b4f 100644 (file)
@@ -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()