erdewit / nest_asyncio

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

fix: running loop should be inset after run_until_complete #25

Closed maartenbreddels closed 4 years ago

maartenbreddels commented 4 years ago

I believe this reflects https://github.com/python/cpython/blob/374d998b507d34a6c0a3816a163926a8ba0c483f/Lib/asyncio/base_events.py#L602

unkcpz commented 4 years ago

I encounter the same need with this feature, but I guess this has to be the side effect when we really need to use this package. If we enter and run until complete the child loop, we can not simple set the _set_running_loop to None since the parent one should still running. At least for in my case this will make ContextVar messed up. @maartenbreddels

maartenbreddels commented 4 years ago

Your timing is perfect. I just got a 'stuck' jupyter kernel because of this, indeed, it's a bad idea. If you didn't send this today... I would have wasted quite some time, thanks!