Skip to content

Bugfix / Correct stopping async cell execution #1069

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

truongle1501
Copy link

@truongle1501 truongle1501 commented Aug 19, 2025

Regarding document:

content = {
# When the kernel starts to handle a message, it will enter the 'busy'
# state and when it finishes, it will enter the 'idle' state.
# The kernel will publish state 'starting' exactly once at process startup.
execution_state : ('busy', 'idle', 'starting')
}

Context:
The async cell execution stopped too early because it hit the below condition while the cell is being executed. This also means there was a moment when iopub message satisfied both msg["parent_header"].get("msg_id") == msg_id and execution_state='idle'

msg = await ensure_async(self.iopub_channel.get_msg(timeout=0))
if msg["parent_header"].get("msg_id") != msg_id:
# not from my request
continue
output_hook(msg)
# stop on idle
if (
msg["header"]["msg_type"] == "status"
and msg["content"]["execution_state"] == "idle"
):
break

This PR aims to set a flag to allow stopping the cell execution only when it saw 'busy' state, which forces the stop condition to run after cell execution starts.

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.

1 participant