From 2e6b6e7e2247e363df6d926fdcebe9750ecf3ab3 Mon Sep 17 00:00:00 2001 From: Alexey Popravka Date: Fri, 4 Jul 2014 15:29:33 +0300 Subject: [PATCH] better ClientResponse.release method --- aiohttp/client.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/aiohttp/client.py b/aiohttp/client.py index 40640ba0e94..f22866477bf 100644 --- a/aiohttp/client.py +++ b/aiohttp/client.py @@ -663,7 +663,14 @@ def close(self, force=False): @asyncio.coroutine def release(self): - yield from self.read() + force = False + try: + while True: + yield from self.content.read() + except Exception as exc: + force = not isinstance(exc, aiohttp.EofStream) + finally: + self.close(force=force) @asyncio.coroutine def wait_for_close(self):