erdewit / nest_asyncio

Patch asyncio to allow nested event loops
BSD 2-Clause "Simplified" License
693 stars 79 forks source link

feature request: unapply #69

Open hjalmarlucius opened 2 years ago

hjalmarlucius commented 2 years ago

It would be great to have an unapply function or the ability to use this as a context manager so that one can allow nested asyncio only in special circumstances, e.g.:

async def afunc():
    ...

def func():
    with nested_asyncio.apply_now() as loop:
        loop.run_until_complete(afunc)
    asyncio.get_event_loop().loop.run_until_complete(afunc) <- raises error
rmorshea commented 1 year ago

Yes please! nest-asyncio can break a lot of other packages that aren't expecting it.