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.

Author lidiz
Recipients asvetlov, lidiz, yselivanov
Date 2020-02-26.19:25:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1582745153.24.0.421575819454.issue39764@roundup.psfhosted.org>
In-reply-to
Content
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: https://github.com/python/cpython/pull/18669

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()
            asyncio.create_task(ag.aclose())
            tasks = asyncio.all_tasks()
            for task in tasks:
                # No AttributeError raised
                task.get_stack()

        self.loop.run_until_complete


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

[1] https://github.com/python/cpython/blob/21da76d1f1b527d62b2e9ef79dd9aa514d996341/Lib/asyncio/base_tasks.py#L27
[2] https://github.com/python/cpython/blob/21da76d1f1b527d62b2e9ef79dd9aa514d996341/Objects/genobject.c#L1329
History
Date User Action Args
2020-02-26 19:25:53lidizsetrecipients: + lidiz, asvetlov, yselivanov
2020-02-26 19:25:53lidizsetmessageid: <1582745153.24.0.421575819454.issue39764@roundup.psfhosted.org>
2020-02-26 19:25:53lidizlinkissue39764 messages
2020-02-26 19:25:53lidizcreate