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. 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