-
Notifications
You must be signed in to change notification settings - Fork 142
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
Not raising StopAsyncIteration exception in debugger #541
Comments
This is the unfortunate artifact of how async loops are implemented. But we should be able to special-case this exception type, like we already do for some others. Although, what if you do want this exception to break, in some other circumstances? I'm not sure if we can determine whether it's raised from the loop, or for some other reason. |
Well @int19h, I think an ability to ignore this Exception would be a great thing.
|
It's not quite an implementation level detail, because it's spec'd as part of the language: https://www.python.org/dev/peps/pep-0492/#asynchronous-iterators-and-async-for Consequently, if you're implementing an async iterator manually, you'll need to raise that exception yourself. And when debugging such code, it can be useful to break on it. It's a relatively rare case compared to using async iterators, so I think there's a good argument for the default experience ignoring it. But we still need to accommodate the other case. |
We could have some more fine-grained support to allow users to define which exceptions should be accepted and which exceptions should be ignored. Maybe we could have in the launch configuration something as:
Those would affect As a note, we do actually already have hardcoded ignoring of What do you think? |
Instead of JSON settings I would intuitively expect a edit button in "raised exception" in vscode. Other than this, I feel atm, it makes async code pretty undebugable because I've to "continue" everytime. I like your idea @fabioz good one. |
When "Raised Exceptions" is checked the exception StopAsyncIteration gets raised everytime when the
async for
loop ends.This can be frustrating because an exception being raised at the end of for loop is not natural.
Code to trigger the exception:
The text was updated successfully, but these errors were encountered: