Skip to content

PyAsyncGenObject causes task.get_stack() raising AttributeError #83945

Closed

Description

@lidizheng
mannequin
BPO 39764
Nosy @asvetlov, @1st1, @miss-islington, @lidizheng
PRs
  • bpo-39764: Make Task.get_stack accept ag_frame #18669
  • [3.8] bpo-39764: Make Task.get_stack accept ag_frame (GH-18669) #18742
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-03-02.13:06:37.014>
    created_at = <Date 2020-02-26.19:25:53.231>
    labels = ['type-bug', '3.9', 'expert-asyncio']
    title = 'PyAsyncGenObject causes task.get_stack() raising AttributeError'
    updated_at = <Date 2020-03-02.13:06:37.013>
    user = 'https://github.com/lidizheng'

    bugs.python.org fields:

    activity = <Date 2020-03-02.13:06:37.013>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-03-02.13:06:37.014>
    closer = 'asvetlov'
    components = ['asyncio']
    creation = <Date 2020-02-26.19:25:53.231>
    creator = 'lidiz'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39764
    keywords = ['patch']
    message_count = 3.0
    messages = ['362722', '363168', '363170']
    nosy_count = 4.0
    nosy_names = ['asvetlov', 'yselivanov', 'miss-islington', 'lidiz']
    pr_nums = ['18669', '18742']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue39764'
    versions = ['Python 3.9']

    Activity

    1. lidizheng commented on Feb 26, 2020

      lidizhengmannequin
      MannequinAuthor

      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: #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]


      [2]
      {"ag_frame", T_OBJECT, offsetof(PyAsyncGenObject, ag_frame), READONLY},

    2. asvetlov commented on Mar 2, 2020

      @asvetlov
      Contributor

      New changeset 4482337 by Lidi Zheng in branch 'master':
      bpo-39764: Make Task.get_stack accept ag_frame (bpo-18669)
      4482337

    3. miss-islington commented on Mar 2, 2020

      @miss-islington
      Contributor

      New changeset 43932dc by Miss Islington (bot) in branch '3.8':
      bpo-39764: Make Task.get_stack accept ag_frame (GH-18669)
      43932dc

    4. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions