Issue 32314: Implement asyncio.run() - Python tracker (original) (raw)

Created on 2017-12-13 21:47 by yselivanov, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4852 merged yselivanov,2017-12-13 21:48
PR 5262 open yselivanov,2018-01-21 18:18
Messages (7)
msg308256 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2017-12-13 21:47
There's a fairly extensive discussion here: https://github.com/python/asyncio/pull/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()!
msg308258 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2017-12-13 22:05
I like avoiding run_forever() -- the function always was too cumbersome.
msg308259 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2017-12-13 22:07
I'll open a separate issue to improve Server's API. AFAIK it's the main reason for having run_forever().
msg308301 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2017-12-14 14:42
New changeset 02a0a19206da6902c3855a1fa09e60b208474cfa by Yury Selivanov in branch 'master': bpo-32314: Implement asyncio.run() (#4852) https://github.com/python/cpython/commit/02a0a19206da6902c3855a1fa09e60b208474cfa
msg308303 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-12-14 14:45
Wow, I really love your new function. Thanks Yury! asyncio examples in the doc look much better now!
msg308308 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2017-12-14 15:35
> 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 :)
msg310381 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-01-21 19:57
New changeset a4afcdfa55ddffa4b9ae3b0cf101628c7bff4102 by Yury Selivanov in branch 'master': bpo-32314: Fix asyncio.run() to cancel runinng tasks on shutdown (#5262) https://github.com/python/cpython/commit/a4afcdfa55ddffa4b9ae3b0cf101628c7bff4102
History
Date User Action Args
2022-04-11 14:58:55 admin set github: 76495
2018-01-21 19:57:01 yselivanov set messages: +
2018-01-21 18🔞29 yselivanov set pull_requests: + <pull%5Frequest5107>
2017-12-14 15:35:15 yselivanov set messages: +
2017-12-14 14:45:16 vstinner set nosy: + vstinnermessages: +
2017-12-14 14:43:04 yselivanov set status: open -> closedresolution: fixedstage: patch review -> resolved
2017-12-14 14:42:24 yselivanov set messages: +
2017-12-13 22:07:44 yselivanov set messages: +
2017-12-13 22:05:32 asvetlov set messages: +
2017-12-13 21:48:25 yselivanov set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest4741>
2017-12-13 21:47:08 yselivanov create