Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asyncio Task.get_stack fails with native coroutines #69055

Closed
habilain mannequin opened this issue Aug 14, 2015 · 6 comments
Closed

Asyncio Task.get_stack fails with native coroutines #69055

habilain mannequin opened this issue Aug 14, 2015 · 6 comments

Comments

@habilain
Copy link
Mannequin

habilain mannequin commented Aug 14, 2015

BPO 24867
Nosy @gvanrossum, @vstinner, @larryhastings, @1st1
Files
  • fix_asyncio_task_get_frame.diff: Patch to fix issue
  • 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 = 'https://github.com/1st1'
    closed_at = <Date 2015-08-14.19:37:17.951>
    created_at = <Date 2015-08-14.15:26:22.263>
    labels = ['release-blocker', 'expert-asyncio']
    title = 'Asyncio Task.get_stack fails with native coroutines'
    updated_at = <Date 2015-08-25.21:35:24.234>
    user = 'https://bugs.python.org/habilain'

    bugs.python.org fields:

    activity = <Date 2015-08-25.21:35:24.234>
    actor = 'python-dev'
    assignee = 'yselivanov'
    closed = True
    closed_date = <Date 2015-08-14.19:37:17.951>
    closer = 'yselivanov'
    components = ['asyncio']
    creation = <Date 2015-08-14.15:26:22.263>
    creator = 'habilain'
    dependencies = []
    files = ['40179']
    hgrepos = []
    issue_num = 24867
    keywords = ['patch']
    message_count = 6.0
    messages = ['248589', '248590', '248607', '248608', '249083', '249161']
    nosy_count = 6.0
    nosy_names = ['gvanrossum', 'vstinner', 'larry', 'python-dev', 'yselivanov', 'habilain']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue24867'
    versions = ['Python 3.5']

    @habilain
    Copy link
    Mannequin Author

    habilain mannequin commented Aug 14, 2015

    I've been playing around with native coroutines and asyncio, and came across an issue with retrieving exceptions from tasks: The get_frame method on a Task in asyncio fails with an AttibuteError because it assumes that gi_frame as the attribute containing the stack frame; with native coroutines it's cr_frame.

    I've attached a quick patch that just uses hasattr to see if gi_frame is present, and if not try cr_frame. This may not be the most elegant solution, but it does fix the issue. If there's any other stuff I can provide to help with this (within reason), just say the word.

    @habilain habilain mannequin added the topic-asyncio label Aug 14, 2015
    @habilain
    Copy link
    Mannequin Author

    habilain mannequin commented Aug 14, 2015

    It should be noted that when I said get_frame in the original comment, I actually meant get_stack

    @habilain habilain mannequin changed the title Asyncio get_frame fails with native coroutines Asyncio Task.get_stack fails with native coroutines Aug 14, 2015
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 14, 2015

    New changeset 53d2a7c023bc by Yury Selivanov in branch '3.4':
    Issue bpo-24867: Fix Task.get_stack() for 'async def' coroutines
    https://hg.python.org/cpython/rev/53d2a7c023bc

    New changeset d25022765186 by Yury Selivanov in branch '3.5':
    Merge 3.4 (Issue bpo-24867)
    https://hg.python.org/cpython/rev/d25022765186

    New changeset c0b7829e3074 by Yury Selivanov in branch 'default':
    Merge 3.5 (issue bpo-24867)
    https://hg.python.org/cpython/rev/c0b7829e3074

    @1st1
    Copy link
    Member

    1st1 commented Aug 14, 2015

    Looks like we didn't have unittests for Task.get_stack()/Task.print_stack().

    Anyways, it's now fixed, I'll make a PR for Larry to get this in 3.5.0rc2.

    @1st1 1st1 closed this as completed Aug 14, 2015
    @1st1 1st1 self-assigned this Aug 14, 2015
    @larryhastings
    Copy link
    Contributor

    Pull request accepted and merged.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 25, 2015

    New changeset 595614c08eeb by Yury Selivanov in branch '3.5':
    Issue bpo-24867: Fix asyncio.Task.get_stack() for 'async def' coroutines
    https://hg.python.org/cpython/rev/595614c08eeb

    New changeset 9b28f41f1353 by Larry Hastings in branch '3.5':
    Merged in 1st1/cpython350 (pull request #5)
    https://hg.python.org/cpython/rev/9b28f41f1353

    New changeset ad48d5a4ef40 by Larry Hastings in branch '3.5':
    Add missing Misc/NEWS item for merged pull request for issue bpo-24867.
    https://hg.python.org/cpython/rev/ad48d5a4ef40

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants