Skip to content

gh-121468: Support async breakpoint in pdb #132576

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

Merged
merged 13 commits into from
Apr 29, 2025

Conversation

gaogaotiantian
Copy link
Member

@gaogaotiantian gaogaotiantian commented Apr 16, 2025

I finally figured out how to support await in pdb without too much hack - we can make the breakpoint itself an awaitable, and everything is simply integrated into the system!

This PR introduced a new function pdb.set_trace_async which the users should await, and with that function, the users can do their awaits in th debugger!


📚 Documentation preview 📚: https://cpython-previews--132576.org.readthedocs.build/

@gaogaotiantian gaogaotiantian marked this pull request as ready for review April 16, 2025 23:44
@gaogaotiantian
Copy link
Member Author

Hi @iritkatriel , do you think this needs to be reviewed by asyncio expert?

@iritkatriel
Copy link
Member

Yes, ideally.

@gaogaotiantian
Copy link
Member Author

@kumaraditya303 I hope I can have this in 3.14 because it's a demanding feature. Could you take a look at it and see if it's a reasonable approach? Thanks!

Lib/pdb.py Outdated
and e.msg == "'await' outside function"
):
try:
self._exec_await(buffer, globals, locals)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be run without the exception from line 891 in the context

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I restructured the code as we know whether it is an await code during compile. The nice side effect is that we don't need to execute the code under the exception context.

@gaogaotiantian
Copy link
Member Author

What do you mean? The link is already in whatsnew entry.

@gaogaotiantian
Copy link
Member Author

@iritkatriel do you have any other concerns about this PR?

Copy link

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@gaogaotiantian
Copy link
Member Author

Hi @iritkatriel , if you don't have any objections I'll merge this in a day or so :)

@iritkatriel
Copy link
Member

Hi @iritkatriel , if you don't have any objections I'll merge this in a day or so :)

Go for it. @kumaraditya303 has approved.

@gaogaotiantian gaogaotiantian merged commit caee16f into python:main Apr 29, 2025
43 checks passed
@gaogaotiantian gaogaotiantian deleted the support-async-breakpoint branch April 29, 2025 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants