Skip to content

Commit

Permalink
Clean up more timeouts when shutting down HTTP clients or finishing t…
Browse files Browse the repository at this point in the history
…ests.
  • Loading branch information
bdarnell committed Feb 21, 2013
1 parent 88e94c8 commit d4167f9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions tornado/curl_httpclient.py
Expand Up @@ -81,6 +81,8 @@ def initialize(self, io_loop, max_clients=10, defaults=None):

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()
Expand Down
1 change: 1 addition & 0 deletions tornado/test/httpclient_test.py
Expand Up @@ -285,6 +285,7 @@ def test_configure_defaults(self):
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
Expand Down
5 changes: 3 additions & 2 deletions tornado/testing.py
Expand Up @@ -223,15 +223,16 @@ def timeout_func():
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
self.io_loop.start()
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()
Expand Down

0 comments on commit d4167f9

Please sign in to comment.