-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
Make pdb asyncio aware #121468
Comments
I have some questions:
|
Switching is basically wait until in that task. Multi-threading is not supported at all in I did not think about async generators specifically, but as far as I understand, it's not that special is it? Maybe we can deal with it when there's a concrete example. What I'm trying to do now is to have some level of support of |
I look forward to try a prototype of this! |
@kumaraditya303 could you take a quick look at #124367? It's just a draft for now because I need to change all the asyncio related pdb doctests before merging it. It implemented step 1. One thing I'd really like to know is if the information |
As for convenience variable, maybe we can have one for the current contextvars used by the task? |
I can remember the enter task and set that task to For the callbacks, one of the issue I had was there could be many and it could be long. Do you think something like
The user can always get the detailed information with
But this line is too long to show in the debugger every time the user stops (it could be even longer). As for the convenience variable, we have a few ways to show that. The simplest is just
Then you can do
which is always correct but a bit boring. Say we have a
Or you can have a proxy to support
Getting the current context is trivial, the question is what the user need to interface with the context. |
Feature or enhancement
Proposal:
Currently pdb does not know anything about asyncio, even though it's a feature officially supported for a long time. I will add supports for asyncio in roughly 3 steps (does not have to be exact 3 PRs):
pdb
will generate some passive info for asyncio. If the user hits a breakpoint inside an asyncio task, there will be a one line message with the current stack indicating which task the user is in. A convenience variable$_asynctask
will be added to refer to the current task.pdb
will provide a way for the user to examine all the tasks in the current event loop with a new command. The user can inspect how many tasks are there and their status. Maybe they can even check the frames for each task.pdb
will enable users to switch between tasks, aka letting users to specify "run until I'm in this task".pdb
will also possibly provide a way for the users to cancel the task.In theory, many of the features are already possible with manual code as
pdb
can execute arbitrary code anyway. However, I believe it's helpful for the users to have a more convenient way to debug their async programs.This was briefly mentioned in the language summit at PyCon this year, no one objected (maybe because they have other stuff that they were more against :) ).
This should not impact any user experience with the existing code that not involves asyncio.
If you have any other suggestions or objections, please let me know.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: