-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Find a way to handle branch events in async for
#128534
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
Comments
The bytecode for async def foo(x):
async for y in x:
A is
One way to instrument this would be to add a |
We still need to add these new branches to |
…ythonGH-130847) * Both branches in a pair now have a common source and are included in co_branches
When instrumenting regular
for
loops, we instrument theFOR_ITER
instruction as theLEFT
branch and thePOP_ITER
instruction as theRIGHT
branch.This doesn't work for
async for
as it uses exceptions to exit the loop.Raising an exception is the documented behavior for exiting a [async] generator, so we will still need to generate an event for the exception being raised, much as we do in
INSTRUMENTED_END_FOR
as well as theBRANCH
events.Linked PRs
async for
loops. #130569async for
#130847The text was updated successfully, but these errors were encountered: