-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
Implement asyncio.run() #76495
Comments
There's a fairly extensive discussion here: python/asyncio#465 In short, asyncio.run() is a pretty straightforward addition, so let's add it. The discussion was more focused on the asyncio.run_forever() proposal. I now think that it shouldn't be implemented in asyncio. Instead we should fix cases where 'loop.run_forever' is usually required. Mainly that's servers, and they are easily fixable by making "Server" an async context manager and implementing a "server.serve_forever()" method. That way, with asyncio.run(): async def serve_something():
async with asyncio.start_server(...) as server:
await server.serve_forever()
asyncio.run(serve_something()) # No loop.run_forever()! |
I like avoiding run_forever() -- the function always was too cumbersome. |
I'll open a separate issue to improve Server's API. AFAIK it's the main reason for having run_forever(). |
Wow, I really love your new function. Thanks Yury! asyncio examples in the doc look much better now! |
This year I'll stay for the sprints at PyCon, and will focus on improving the docs further. I needed asyncio.run for that :) |
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: