Skip to content

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.

and msg["content"]["execution_state"] == "idle"
):
break
if msg["header"]["msg_type"] == "status":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I see that this fixes a status message from a previous cell.

Rather than waiting for busy and then idle, which would have a similar issue, just a bit farther back in time, I think the fix might be to add a check for and msg["parent_header"].get("msg_id") == msg_id to make sure we are stopping on the idle message from this request, rather than any idle message.

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.

2 participants