Skip to content

Commit 100e45c

Browse files
committed
Merge pull request #17
2 parents 5f32678 + 623dbb1 commit 100e45c

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
packages=find_packages(),
6262
install_requires=[
6363
"trio",
64+
"async_generator >= 1.6",
6465
],
6566
# This means, just install *everything* you see under trio/, even if it
6667
# doesn't look like a source file, so long as it appears in MANIFEST.in:

trio_asyncio/adapter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This code implements a clone of the asyncio mainloop which hooks into
22
# Trio.
33

4-
import inspect
4+
from async_generator import isasyncgenfunction
55
import trio_asyncio
66

77
# import logging
@@ -13,7 +13,7 @@
1313

1414

1515
def trio2aio(proc):
16-
if inspect.isasyncgenfunction(proc):
16+
if isasyncgenfunction(proc):
1717

1818
@wraps(proc)
1919
def call(*args, **kwargs):

trio_asyncio/util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import trio
55
import asyncio
66
import sys
7+
from async_generator import async_generator, yield_
78

89
__all__ = ['run_future']
910

@@ -50,6 +51,7 @@ def abort_cb(raise_cancel_arg):
5051
STOP = object()
5152

5253

54+
@async_generator
5355
async def run_generator(loop, async_generator):
5456
task = trio.hazmat.current_task()
5557
raise_cancel = None
@@ -79,7 +81,7 @@ def abort_cb(raise_cancel_arg):
7981
item = await trio.hazmat.wait_task_rescheduled(abort_cb)
8082
if item is STOP:
8183
break
82-
yield item
84+
await yield_(item)
8385

8486
except asyncio.CancelledError as exc:
8587
if raise_cancel is not None:

0 commit comments

Comments
 (0)