Skip to content

Commit

Permalink
Fix python 3.8 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
vxgmichel committed Feb 5, 2020
1 parent 21e549a commit 385558f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions aiostream/aiter_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,12 @@ async def __aexit__(self, typ, value, traceback):
# Look for an aclose method
aclose = getattr(self._aiterator, 'aclose', None)

# The ag_running attribute only exists for python >= 3.8
# The ag_running attribute has been introduced with python 3.8
running = getattr(self._aiterator, 'ag_running', False)
closed = not getattr(self._aiterator, 'ag_frame', True)

# A RuntimeError is raised if aiterator is already running
if aclose and not running:
# A RuntimeError is raised if aiterator is running or closed
if aclose and not running and not closed:
try:
await aclose()

Expand Down

0 comments on commit 385558f

Please sign in to comment.