get_all_awaited_by()
shows incorrect call stacks in awaited_by relationships
#135371
Labels
type-bug
An unexpected behavior, bug, or error
Uh oh!
There was an error while loading. Please reload this page.
The current asyncio debugging tools (
python -m asyncio ps
andpython -m asyncio pstree
) provide limited visibility into complex async execution patterns, making it extremely difficult to debug production asyncio applications.The fundamental issue is that the current implementation only shows external task dependencies without revealing the internal coroutine call stack. This creates a wrong output because developers cannot see where within a task's execution the code is currently suspended.
Current vs Correct Output
Consider this example of a complex async application with nested coroutines:
Current Implementation
The existing debugging output makes it nearly impossible to understand what's happening:
Table output:
Tree output:
This output is problematic because for the leaf tasks (like the
foo2
tasks), there's no indication of their internal execution state - developers can't tell that these tasks are suspended inasyncio.sleep()
calls.Correct Implementation
The correct debugging output transforms the debugging experience by providing correct execution context:
Table output with dual information display:
Tree output with complete execution context:
The correct output immediately reveals crucial information that was previously hidden. Developers can now see that the
foo2
tasks are suspended insleep
calls, thefoo1.0
task is suspended in thefoo12
function, and the mainTask-1
is suspended in therunner
function. This level of detail transforms debugging from guesswork into precise analysis.Linked PRs
The text was updated successfully, but these errors were encountered: