Python 3.14+Async programmingfunction
asyncio.capture_call_graph()
call graph
Captures the async call graph: what a task is executing and who awaits it. Returns a FutureCallGraph, or None outside a task.
Syntax
graph = asyncio.capture_call_graph(future=None, /, *, depth=1, limit=None)
A plain traceback in asyncio stops at the task boundary: you see the coroutine's own stack but not which task awaits it. The graph adds awaited_by, the chain of waiting tasks up to main. With no argument the current task is used; limit trims the stacks, and limit=0 keeps only the await links, which is cheaper. Added in 3.14.
Examples
# Python 3.14+
import asyncio
async def child():
graph = asyncio.capture_call_graph()
print(graph.future.get_name()) # → child
print([g.future.get_name() for g in graph.awaited_by]) # → ['Task-1'] — её ждёт main
print(asyncio.capture_call_graph(limit=0).call_stack) # → ()
async def main():
await asyncio.create_task(child(), name='child')
asyncio.run(main())
See also
Open in the full glossarydocs.python.orgReport an inaccuracy