Skip to content

Commit

Permalink
Properly close sessions in _SessionRequestContextManager (#2441)
Browse files Browse the repository at this point in the history
* Properly close sessions in _SessionRequestContextManager

* Add news fragment
  • Loading branch information
hynek authored and asvetlov committed Oct 30, 2017
1 parent 4cc392f commit 10e0d97
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/2441.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_SessionRequestContextManager closes the session properly now.
8 changes: 4 additions & 4 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 10e0d97

Please sign in to comment.