Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.8 compatibility (asynchronous generator is already running) #62

Merged
merged 2 commits into from
Feb 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion aiostream/aiter_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ async def __aexit__(self, typ, value, traceback):
if not getattr(self._aiterator, "ag_frame", True):
return False

# Cannot throw at the moment
if getattr(self._aiterator, 'ag_running', False):
return False

# Throw
try:
await self._aiterator.athrow(typ, value, traceback)
Expand Down Expand Up @@ -183,7 +187,7 @@ async def __aexit__(self, typ, value, traceback):

# Work around bpo-35409
except GeneratorExit:
pass
pass # pragma: no cover
finally:
self._state = self._FINISHED

Expand Down
6 changes: 6 additions & 0 deletions tests/test_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ async def test_merge(assert_run, event_loop):
await assert_run(ys[:3], [0, 1, 2])
assert event_loop.steps == [1, 1]

with event_loop.assert_cleanup():
xs = stream.just(1) + stream.never()
ys = xs | pipe.merge(xs) | pipe.timeout(1)
await assert_run(ys, [1, 1], asyncio.TimeoutError())
assert event_loop.steps == [1]


@pytest.mark.asyncio
async def test_ziplatest(assert_run, event_loop):
Expand Down