python-trio / trio-asyncio

a re-implementation of the asyncio mainloop on top of Trio
Other
188 stars 37 forks source link

Monkeypatching of loop functions doesn't cover all cases #83

Open oremanj opened 4 years ago

oremanj commented 4 years ago

A user on Gitter discovered that this simple-seeming code doesn't work:

from asyncio import get_running_loop
from trio import run
from trio_asyncio import aio_as_trio, open_loop

async def main():
    async def inner():
        return get_running_loop()

    async with open_loop():
        print(await aio_as_trio(inner)())

run(main)

There are two issues here: