Skip to content

Commit

Permalink
if session is never to be instantiated, do not try to close it
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin Raney committed Aug 24, 2021
1 parent e323e80 commit 01f303a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/_restclient/src/hydrotools/_restclient/_restclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ def headers(self) -> dict:

def close(self) -> None:
""" Release aiohttp.ClientSession """
# Session never instantiated, thus cannot be closed
session = getattr(self, "_session", None)
if session is None:
return

if not self._session.closed:
if not self._loop.is_closed():
self._add_to_loop(self._session.close())
Expand Down

0 comments on commit 01f303a

Please sign in to comment.