From 253607ec7b3280b087b59f1f4f8695d1194b9b4c Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Wed, 23 Jul 2014 22:18:27 -0400 Subject: [PATCH] Fix a potential leak of an unclosed AsyncHTTPClient. --- tornado/test/httpclient_test.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tornado/test/httpclient_test.py b/tornado/test/httpclient_test.py index 124239992..225911087 100644 --- a/tornado/test/httpclient_test.py +++ b/tornado/test/httpclient_test.py @@ -324,10 +324,12 @@ Transfer-Encoding: chunked # Construct a new instance of the configured client class client = self.http_client.__class__(self.io_loop, force_instance=True, defaults=defaults) - client.fetch(self.get_url('/user_agent'), callback=self.stop) - response = self.wait() - self.assertEqual(response.body, b'TestDefaultUserAgent') - client.close() + try: + client.fetch(self.get_url('/user_agent'), callback=self.stop) + response = self.wait() + self.assertEqual(response.body, b'TestDefaultUserAgent') + finally: + client.close() def test_304_with_content_length(self): # According to the spec 304 responses SHOULD NOT include -- 2.47.2