From f5f062ceff1747b266ef2b9e0edcd57ef071a7e4 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Mon, 30 Oct 2017 11:10:01 +0100 Subject: [PATCH 1/2] Properly close sessions in _SessionRequestContextManager --- aiohttp/client.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aiohttp/client.py b/aiohttp/client.py index 7eaf4aea580..62b879449c6 100644 --- a/aiohttp/client.py +++ b/aiohttp/client.py @@ -724,16 +724,16 @@ def __init__(self, coro, session): def __iter__(self): try: return (yield from self._coro) - except: - self._session.close() + except BaseException: + yield from self._session.close() raise if PY_35: def __await__(self): try: return (yield from self._coro) - except: - self._session.close() + except BaseException: + yield from self._session.close() raise From eb3ba3f2a63e0ba15bcbec4004957f9a94f68073 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Mon, 30 Oct 2017 11:16:23 +0100 Subject: [PATCH 2/2] Add news fragment --- CHANGES/2441.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 CHANGES/2441.bugfix diff --git a/CHANGES/2441.bugfix b/CHANGES/2441.bugfix new file mode 100644 index 00000000000..86f518b4ed4 --- /dev/null +++ b/CHANGES/2441.bugfix @@ -0,0 +1 @@ +_SessionRequestContextManager closes the session properly now.