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: PyAsyncGenObject causes task.get_stack() raising AttributeError
Type: behavior Stage: resolved
Components: asyncio Versions: Python 3.9
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, lidiz, miss-islington, yselivanov
Priority: normal Keywords: patch

Created on 2020-02-26 19:25 by lidiz, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18669 merged lidiz, 2020-02-26 19:25
PR 18742 merged miss-islington, 2020-03-02 12:46
Messages (3)
msg362722 - (view) Author: Lidi Zheng (lidiz) * Date: 2020-02-26 19:25
This issue exists since 3.6.

The implementation of get stack on Task is looking for two attribute [1]: "cr_frame" for coroutines, "gi_frame" for generators (legacy coroutines). However, PyAsyncGenObject provides none of them but "ag_frame" [2].

Fix PR:

A simple reproduce:

    def test_async_gen_aclose_compatible_with_get_stack(self):
        async def async_generator():
            yield object()

        async def run():
            ag = async_generator()
            tasks = asyncio.all_tasks()
            for task in tasks:
                # No AttributeError raised


I found this in my project I want to view who created the Tasks.

msg363168 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-03-02 12:46
New changeset 4482337decdbd0c6e2150346a68b3616bda664aa by Lidi Zheng in branch 'master':
bpo-39764: Make Task.get_stack accept ag_frame (#18669)
msg363170 - (view) Author: miss-islington (miss-islington) Date: 2020-03-02 13:04
New changeset 43932dc1eaf36d75b2ee0420d8be747001315c26 by Miss Islington (bot) in branch '3.8':
bpo-39764: Make Task.get_stack accept ag_frame (GH-18669)
Date User Action Args
2022-04-11 14:59:27adminsetgithub: 83945
2020-03-02 13:06:37asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-03-02 13:04:07miss-islingtonsetmessages: + msg363170
2020-03-02 12:46:07miss-islingtonsetkeywords: + patch
nosy: + miss-islington

pull_requests: + pull_request18097
stage: patch review
2020-03-02 12:46:05asvetlovsetmessages: + msg363168
2020-02-26 19:25:53lidizcreate