File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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:
Original file line number Diff line number Diff line change 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
55import trio_asyncio
66
77# import logging
1313
1414
1515def trio2aio (proc ):
16- if inspect . isasyncgenfunction (proc ):
16+ if isasyncgenfunction (proc ):
1717 @wraps (proc )
1818 def call (* args ):
1919 return trio_asyncio .wrap_generator (proc , * args )
Original file line number Diff line number Diff line change 44import trio
55import asyncio
66import sys
7+ from async_generator import async_generator , yield_
8+
79
810__all__ = ['run_future' ]
911
@@ -49,6 +51,8 @@ def abort_cb(raise_cancel_arg):
4951
5052STOP = object ()
5153
54+
55+ @async_generator
5256async def run_generator (loop , async_generator ):
5357 task = trio .hazmat .current_task ()
5458 raise_cancel = None
@@ -78,7 +82,7 @@ def abort_cb(raise_cancel_arg):
7882 item = await trio .hazmat .wait_task_rescheduled (abort_cb )
7983 if item is STOP :
8084 break
81- yield item
85+ await yield_ ( item )
8286
8387 except asyncio .CancelledError as exc :
8488 if raise_cancel is not None :
You can’t perform that action at this time.
0 commit comments