New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event loop implementation docs advertise set_event_loop which doesn't work with asyncio.run #82604
Comments
The docs of SelectorEventLoop and ProactorEventLoop contain examples that call asyncio.set_event_loop: selector = selectors.SelectSelector()
loop = asyncio.SelectorEventLoop(selector)
asyncio.set_event_loop(loop) But this won't have any effect on code that uses asyncio.run(), because asyncio.run() creates a fresh event loop. Since asyncio.run() is the recommended way to execute async code and is used consistently throughout the documentation, this might be confusing to someone who tries to e.g. use the proactor loop on Windows. I propose the following:
|
Yes, docs updates sound good. |
It doesn't seem to work either for asyncio.get_event_loop, especially when using asyncio.wait(), the loop complains that "RuntimeError: Task <Task pending coro=<Event.wait() running at lib\asyncio\locks.py:293> cb=[_wait.<locals>._on_completion() at lib\asyncio\tasks.py:440]> got Future <Future pending> attached to a different loop" |
My bad, I did not check that asyncio.Event() was called before the application has a chance to properly set_event_loop with custom one. |
(cherry picked from commit 53503ff) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
(cherry picked from commit 53503ff) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: