This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Make asyncio methods documented as coroutines - coroutines.
Type: Stage: resolved
Components: asyncio Versions: Python 3.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: yselivanov Nosy List: asvetlov, yselivanov
Priority: normal Keywords: patch

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

Pull Requests
URL Status Linked Edit
PR 4872 merged yselivanov, 2017-12-14 21:02
PR 4996 merged asvetlov, 2017-12-23 20:35
PR 5392 merged yselivanov, 2018-01-28 18:17
Messages (3)
msg308339 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2017-12-14 20:58
There's a handful of event loop methods that are currently documented as coroutines, but in reality they return asyncio.Future:

* loop.sock_sendall, 
* loop.sock_accept, 
* loop.sock_recv, and 
* loop.run_in_executor.

These methods need to become proper coroutines beacause:

1. loop.create_task(loop.sock_recv(..)) fails with a cryptic error.

2. It's harder for us to refactor the code keeping these functions as regular functions returning Futures.  Once asyncio was broken because of the bug in loop.sock_connect() because of a complex refactoring.  After we converted it to a coroutine in 3.6, we received 0 complaints, but the code became simpler.

3. It's easier to read the source code of asyncio, when all methods that are documented as coroutines are actually coroutines.

4. This downgrades the role of 'asyncio.ensure_future()' function.  Basically, when a user needs a task, they can now use create_task() (which won't fail on some "coroutines" sometimes).  asyncio users will be advised to design APIs in their programs and libraries around async/await and not Future objects.
msg308360 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2017-12-15 01:53
New changeset 19a44f63c738388ef3c8515348b4ffc061dfd627 by Yury Selivanov in branch 'master':
bpo-32327: Convert asyncio functions documented as coroutines to coroutines. (#4872)
msg310981 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-01-28 19:09
New changeset bec2372b7e1da5dfdbadaf242aa8e994b164cace by Yury Selivanov in branch 'master':
bpo-32327: Revert loop.run_in_executor behaviour: return a Future. (#5392)
Date User Action Args
2022-04-11 14:58:55adminsetgithub: 76508
2018-01-28 19:09:42yselivanovsetmessages: + msg310981
2018-01-28 18:17:20yselivanovsetpull_requests: + pull_request5227
2017-12-23 20:35:37asvetlovsetpull_requests: + pull_request4885
2017-12-15 01:53:44yselivanovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-12-15 01:53:29yselivanovsetmessages: + msg308360
2017-12-14 21:02:21yselivanovsetkeywords: + patch
stage: patch review
pull_requests: + pull_request4765
2017-12-14 20:59:10yselivanovsetnosy: + asvetlov
2017-12-14 20:58:58yselivanovcreate