Repository navigation
Close cells the pseudo-sync runner cannot finish - #15459
Open
jenshnielsen wants to merge 2 commits into
Open
jenshnielsen wants to merge 2 commits into
jenshnielsen wants to merge 2 commits into
Conversation
When a cell needs an event loop but runs through _pseudo_sync_runner (e.g. in a shell whose should_run_async returns False), the runner raised RuntimeError but left the cell's coroutine suspended. The garbage collector closed it at some arbitrary later point, and the bare excepts in run_code and run_ast_nodes reported the resulting GeneratorExit as an error of whichever cell was running then, even replacing that cell's traceback. Close the coroutine before raising, and let GeneratorExit from an async cell unwind through run_code and run_ast_nodes instead of reporting it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Undoing a monkeypatch of a method on the shell instance leaves the bound method behind as an instance attribute. That shadowed the class-level showtraceback that test_set_show_tracebacks_none sets later, which made it fail whenever it ran after this test, as in the oldest-deps jobs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
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
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.
I ran into a corner case where generator exists suddenly showed up for seemingly random cells.
Claude has generated the below suggestion for a fix and an example here that shows the issue.
I admit that I am not a deep expert on how the async executor code works in ipython but I have validated the fix and the explanation makes sense to me.
Clauds explanation below:
When a cell needs an event loop but runs through _pseudo_sync_runner (e.g. in a shell whose should_run_async returns False), the runner raised RuntimeError but left the cell's coroutine suspended. The garbage collector closed it at some arbitrary later point, and the bare excepts in run_code and run_ast_nodes reported the resulting GeneratorExit as an error of whichever cell was running then, even replacing that cell's traceback.
Close the coroutine before raising, and let GeneratorExit from an async cell unwind through run_code and run_ast_nodes instead of reporting it.