GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Async Call-Stack Reconstruction · Issue #91048 · python/cpython

Async Call-Stack Reconstruction #91048

New issue
Copy link
New issue
Copy link
Closed
Closed
Async Call-Stack Reconstruction#91048
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-asynciotype-featureA feature request or enhancementA feature request or enhancement

Description

mpage
mannequin
opened on Mar 1, 2022
Issue body actions
BPO 46892
Nosy @gvanrossum, @DinoV, @asvetlov, @1st1, @kumaraditya303, @itamaro, @mpage

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 = None
created_at = <Date 2022-03-01.22:13:38.844>
labels = ['interpreter-core', '3.11', 'type-feature', 'expert-asyncio']
title = 'Async Call-Stack Reconstruction'
updated_at = <Date 2022-03-12.09:30:23.838>
user = 'https://github.com/mpage'

bugs.python.org fields:

activity = <Date 2022-03-12.09:30:23.838>
actor = 'asvetlov'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Interpreter Core', 'asyncio']
creation = <Date 2022-03-01.22:13:38.844>
creator = 'mpage'
dependencies = []
files = []
hgrepos = []
issue_num = 46892
keywords = []
message_count = 5.0
messages = ['414301', '414884', '414930', '414948', '414985']
nosy_count = 7.0
nosy_names = ['gvanrossum', 'dino.viehland', 'asvetlov', 'yselivanov', 'kumaraditya', 'itamaro', 'mpage']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue46892'
versions = ['Python 3.11']

Linked PRs

  • gh-91048: Add support for reconstructing async call stacks #103976
  • GH-91048: Add utils for capturing async call stack for asyncio programs and enable profiling #124640
  • GH-91048: Don't attempt to run on FreeBSD #129189
  • gh-91048: Also clear and set ts->asyncio_running_task with eager tasks #129197
  • gh-91048: Improve example in asyncio-graph.rst doc #129224
  • gh-91048: fix thread safety for asyncio stack introspection APIs #129399
  • GH-91048: Correct error path in testexternalinspection #129557
  • gh-91048: fix _asyncio.future_discard_from_awaited_by #129731
  • gh-91048: Add ability to list all pending asyncio tasks in a process remotely #132807
  • gh-91048: Refactor _testexternalinspection and add Windows support #132852
  • gh-91048: Fix _testexternalinspection.c on FreeBSD #132945
  • gh-91048: Prevent optimizing away the asyncio debug offsets structure on Windows #132963
  • gh-91048: Chain some exceptions in _testexternalinspection.c #132970
  • GH-91048: Add utils for printing the call stack for asyncio tasks #133284
  • gh-133141: Relax test_async_global_awaited_by to fix flakyness #133368
  • gh-91048: Add filename and line number to external inspection routines #133385
  • GH-91048: Minor fixes for _remotedebugging & rename to _remote_debugging #133398
  • gh-91048: Add filename:line_no information to asyncio pstree #133478
  • gh-91048: Fix error path result in _remote_debugging_module #134347
  • [3.14] gh-91048: Fix error path result in _remote_debugging_module (GH-134347) #134399
  • gh-91048: Refactor and optimize remote debugging module #134652
  • [3.14] gh-91048: Refactor and optimize remote debugging module (#134652) #134673
  • gh-91048: Add better error messages for remote debugging for CI builds #134682
  • gh-91048: Guard against TARGET_OS_OSX for compat with simulators in remote_debug.h #134711
  • gh-91048: Correct Apple platform includes for iOS #134712
  • [3.14] gh-91048: Correct Apple platform includes for iOS. (GH-134712) #134714
  • [3.14] gh-91048: Add better error messages for remote debugging for CI builds (GH-134682) #134719
  • gh-91048: Reorder result tuple of parse_code_object #134898
  • [3.14] gh-91048: Reorder result tuple of parse_code_object (GH-134898) #134956
  • gh-91048: Reorder result tuple in asyncio/tools.py #134957
  • gh-91048: Fix external inspection multi-threaded performance #136005
  • [3.14] gh-91048: Fix external inspection multi-threaded performance (GH-136005) #136080
  • gh-91048: Revert the memory cache removal for remote debugging #136440
  • [3.14] gh-91048: Revert the memory cache removal for remote debugging (GH-136440) #136443
  • gh-91048: Refactor common data into context object in Modukes/_remote_debugging #142879
Reacted by Oliver Mannion and Wenbin Hou

Activity

Next
  1. mpage commented on Mar 1, 2022

    @mpage
    mpagemannequin
    on Mar 1, 2022
    MannequinAuthor
    More actions

    Profiling tools that use the call-stack (i.e. all of them) paint an incomplete picture of what’s really going on in async-heavy codebases. They can only show the stack of the currently executing task; they miss the chain of awaitables that are transitively waiting on the current task. To remedy this, we have added support in Cinder to expose the async call-stack. This consists of the call stack for the currently executing task, followed by the chain of awaitables that are transitively reachable from the currently executing task. See below for a clarifying example.

    async def f1():
      return await f2()
    
    async def f2():
      return await asyncio.ensure_future(f3())
    
    async def f3():
      return await f4()
    
    async def f4():
      await asyncio.sleep(10)
      return 42
    

    When retrieved from f4, the two different stacks (top-of-stack last) are:
    sync - [f3, f4]
    async - [f1, f2, f3, f4]

    We’d like to merge our implementation into CPython so that other heavy users of asyncio can benefit. This will consist of a few parts:

    1. A new limited C-API to set and retrieve the “awaiter” of an awaitable object.
    2. Additions to PyAsyncMethods to store function pointers for setting and retrieving the awaiter on instances.
    3. An API in managed code to retrieve the async call stack as a list of fully qualified names (i.e. <module>:<class>.<function>).
    Reacted by Bruno Cabral, Itamar Oren, Zsolt Dollenstein, Jon Janzen, gfolkmanis-nhgh, Zeke Marffy, Savio Mak, Isaac Nygaard and Daniel Limón
  2. mpage
    added
    3.11only security fixesonly security fixes
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    topic-asyncio
    type-featureA feature request or enhancementA feature request or enhancement
    on Mar 1, 2022
  3. asvetlov commented on Mar 11, 2022

    @asvetlov
    asvetlov
    on Mar 11, 2022
    Contributor
    More actions

    We’d like to merge our implementation into CPython

    Could you provide a link first, please?

  4. mpage commented on Mar 11, 2022

    @mpage
    mpagemannequin
    on Mar 11, 2022
    MannequinAuthor
    More actions

    Sorry for the confusion, I'm working on a PR. I filed the BPO to gauge interest in the feature.

  5. gvanrossum commented on Mar 11, 2022

    @gvanrossum
    gvanrossum
    on Mar 11, 2022
    Member
    More actions

    I've recently dabbled a bit in some new primitives for asyncio, and based on that experience I think this would be very useful.

    IIRC Trio does this (presumably at considerable cost) in userland.

  6. asvetlov commented on Mar 12, 2022

    @asvetlov
    asvetlov
    on Mar 12, 2022
    Contributor
    More actions

    The idea looks interesting.
    The devil in the details I guess.
    I'm curious what is the memory and performance penalty.
    Waiting for the PR as the discussion starting point.

  7. ezio-melotti
    transferred this issue fromon Apr 10, 2022
  8. ezio-melotti
    added this to asyncioon Jul 17, 2022
  9. 170 remaining items

    Load more actions
  10. github-project-automation
    moved this from Todo to Done in asyncioon Aug 18, 2025
  11. Agent-Hellboy
    added 2 commits that reference this issue on Aug 19, 2025

    pythongh-91048: Fix external inspection multi-threaded performance (p…

    af2128d

    pythongh-91048: Revert the memory cache removal for remote debugging (p…

    1a219b5
  12. kumaraditya303
    added a commit that references this issue on Sep 9, 2025

    [3.14] pythongh-91048: Revert the memory cache removal for remote deb…

    cfc1321
  13. pablogsal
    added 5 commits that reference this issue on Dec 17, 2025

    pythongh-91048: Refactor common data into context object in Modukes/_…

    81b29a0

    pythongh-91048: Refactor common data into context object in Modukes/_…

    f85996c

    pythongh-91048: Refactor common data into context object in Modukes/_…

    69b335c

    pythongh-91048: Refactor common data into context object in Modukes/_…

    428b62f

    gh-91048: Refactor common data into context object in Modules/_remote…

    77b56ea
  14. gostak-dd
    added 4 commits that reference this issue on Jun 2, 2026

    pythongh-91048: Fix error path result in _remote_debugging_module (py…

    b545955

    pythongh-91048: Refactor and optimize remote debugging module (python…

    624cf34

    pythongh-91048: Correct Apple platform includes for iOS. (python#134712)

    5139145

    pythongh-91048: Add better error messages for remote debugging for CI…

    ff60a93
  15. chrisguidry
    added 2 commits that reference this issue on Jul 20, 2026

    Judge a cancelled task by its state, not its cancel message

    f2a8af8

    Confirm subscriptions before ready; bound TCP connects (#448)

    733772c
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

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-asynciotype-featureA feature request or enhancementA feature request or enhancement

    Projects

    • asyncio
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.