From 73016c4f09ebc1ea087cd90e80a0d5163690d250 Mon Sep 17 00:00:00 2001 From: Nicolas Braem Date: Wed, 21 Jan 2015 14:46:36 -0800 Subject: [PATCH 1/2] connection leak fix for #253 --- aiohttp/connector.py | 1 - 1 file changed, 1 deletion(-) diff --git a/aiohttp/connector.py b/aiohttp/connector.py index 49a7fd76341..cfeded90fb3 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -199,7 +199,6 @@ def _release(self, key, req, transport, protocol, *, should_close=False): reader = protocol.reader if should_close or (reader.output and not reader.output.at_eof()): - self._conns.pop(key, None) transport.close() else: conns = self._conns.get(key) From 5dd86d006094ab559368218461287610cfe2a930 Mon Sep 17 00:00:00 2001 From: Nicolas Braem Date: Thu, 22 Jan 2015 01:20:23 -0800 Subject: [PATCH 2/2] make sure tests pass for #253 --- aiohttp/connector.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aiohttp/connector.py b/aiohttp/connector.py index cfeded90fb3..6027a38f560 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -199,6 +199,9 @@ def _release(self, key, req, transport, protocol, *, should_close=False): reader = protocol.reader if should_close or (reader.output and not reader.output.at_eof()): + conns = self._conns.get(key) + if conns is not None and len(conns) == 0: + self._conns.pop(key, None) transport.close() else: conns = self._conns.get(key)