classification
Title: Expose the coroutine object in asyncio task objects
Type: enhancement Stage: resolved
Components: asyncio Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alex.gronholm, asvetlov, miss-islington, yselivanov
Priority: normal Keywords: patch

Created on 2019-05-21 20:45 by alex.gronholm, last changed 2019-05-30 15:34 by asvetlov. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13680 merged alex.gronholm, 2019-05-30 12:24
Messages (4)
msg343092 - (view) Author: Alex Grönholm (alex.gronholm) * Date: 2019-05-21 20:45
Both curio and trio expose the coroutine object belonging to a task as the "coro" attribute. Asyncio exposes this as "_coro" (as does uvloop) but it would be nice to have at least a read-only attribute exposing this as part of the public API.

In some of my libraries I need this object, sometimes for debugging and other times for implementing "crazy" schemes like running parts of the the coroutine function code in a worker thread.
msg343093 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2019-05-21 20:46
I've no problem with this. We can add a 'get_coro()' Task method (this is in line with asyncio usually having the "getter" api as opposed to properties).
msg343095 - (view) Author: Alex Grönholm (alex.gronholm) * Date: 2019-05-21 20:54
I'll look into making a PR.
msg343982 - (view) Author: miss-islington (miss-islington) Date: 2019-05-30 15:30
New changeset 98ef92002ec289bf8086b0ef3d4f96c2589f4e68 by Miss Islington (bot) (Alex Grönholm) in branch 'master':
bpo-36999: Add asyncio.Task.get_coro() (GH-13680)
https://github.com/python/cpython/commit/98ef92002ec289bf8086b0ef3d4f96c2589f4e68
History
Date User Action Args
2019-05-30 15:34:33asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-05-30 15:30:16miss-islingtonsetnosy: + miss-islington
messages: + msg343982
2019-05-30 12:24:45alex.gronholmsetkeywords: + patch
stage: patch review
pull_requests: + pull_request13568
2019-05-21 20:54:28alex.gronholmsetmessages: + msg343095
2019-05-21 20:46:47yselivanovsetmessages: + msg343093
2019-05-21 20:45:37alex.gronholmcreate