-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-135371: Fix asyncio introspection output to include internal coroutine chains #135436
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
Open
pablogsal
wants to merge
8
commits into
python:main
Choose a base branch
from
pablogsal:better_coros-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,847
−672
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…acks This commit refactors the C module to provide richer debugging information by introducing structured data types and exposing internal coroutine call stacks. The improvement transforms the debugging output from showing only external task dependencies to revealing the complete execution context. The key enhancement is the ability to display both the internal coroutine call stack (what the task is doing internally) and the external awaiter chain (what the task is waiting for). This dual perspective makes it much easier to understand complex async execution patterns. Before this change, the debugging output only showed file paths without function names or internal call stacks. With this improvement, developers can now see the complete picture: "foo2 -> sleep" shows the task is in a sleep call within the foo2 function, while the awaiter chain shows the external dependency structure. The implementation replaces raw tuples with structured sequences: - FrameInfo: Function name, filename, and line number - CoroInfo: Call stack and associated task name - TaskInfo: Task ID, name, coroutine stack, and awaiter relationships - ThreadInfo: Thread ID and frame information - AwaitedInfo: Thread ID and list of awaited tasks This structured approach eliminates magic indices and provides better type safety and introspection capabilities.
This commit updates the asyncio debugging tools to work with the enhanced structured data from the remote debugging module. The tools now process and display both internal coroutine stacks and external awaiter chains, providing much more comprehensive debugging information. The key improvements include: 1. Enhanced table display: Now shows both "coroutine stack" and "awaiter chain" columns, clearly separating what a task is doing internally vs what it's waiting for externally. 2. Improved tree rendering: Displays complete coroutine call stacks for leaf tasks, making it easier to understand the actual execution state of suspended coroutines. 3. Better cycle detection: Optimized DFS algorithm for detecting await cycles in the task dependency graph. 4. Structured data handling: Updated to work with the new FrameInfo, CoroInfo, TaskInfo, and AwaitedInfo structured types instead of raw tuples. The enhanced output transforms debugging from showing only file paths to revealing function names and complete call stacks, making it much easier to understand complex async execution patterns and diagnose issues in production asyncio applications.
This commit updates the test suite to work with the new structured data types introduced in the remote debugging module and asyncio tools. The tests now use proper FrameInfo, CoroInfo, TaskInfo, and AwaitedInfo structures instead of raw tuples. The test updates ensure that the enhanced debugging capabilities are properly validated, including: 1. Structured data type handling in test mock data 2. Verification of coroutine stack extraction and formatting 3. Testing of both internal coroutine stacks and external awaiter chains 4. Validation of the improved table and tree output formats These changes maintain comprehensive test coverage while adapting to the more sophisticated data structures that enable better async debugging output. The tests verify that the debugging tools correctly process and display the enhanced coroutine execution information, ensuring the new features work reliably in production environments.
This commit updates the What's New documentation to showcase the improved async debugging capabilities introduced in the remote debugging module and asyncio tools. The documentation now demonstrates the enhanced output format that provides much more detailed execution information. The key documentation updates include: 1. Updated example output showing both "coroutine stack" and "awaiter chain" columns in the table format, clearly distinguishing between internal task execution state and external dependencies. 2. Enhanced tree output examples that include function names and complete file paths with line numbers, making the debugging information much more actionable for developers. 3. Addition of cycle detection error example showing how the tools handle problematic await patterns that could indicate programming issues. The updated examples demonstrate how the enhanced debugging output transforms from showing basic file paths to revealing detailed function call stacks and execution context. This improvement makes it significantly easier for developers to understand complex async execution patterns and debug issues in production asyncio applications, especially when dealing with nested coroutines and complex task hierarchies.
d1a5d17
to
ec809b5
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
get_all_awaited_by()
shows incorrect call stacks in awaited_by relationships #135371📚 Documentation preview 📚: https://cpython-previews--135436.org.readthedocs.build/