Ensure kernel is ready before sending execute_request messages #350
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.
Fixes #349.
It is possible to send an
execute_requestmessage too early to anipykernelkernel, before it is ready to process that message. The recommendation is to send akernel_info_requestmessage first and wait for the reply, which is the change added here. There is some complicated logic in somejupyterlibraries to deal with this which boils down to wait for thekernel_info_replymessage and you will be OK.Without the
kernel_info_requestit is possible to get timing-related errors. This has always been the case but is more likely now withipykernel >= 7as more resources (threads, ZMQ sockets) are created.This fixes the problem for me locally on Linux, let's see if CI is happy with it.
I suspect there are other libraries downstream of
ipykernelthat also suffer from this, so I am hoping to make some changes toipykernelto improve the situation. There are separate proposals to improvejupyter_server's handling of it, and to allow the kernel to push a "I am ready" notification rather than usingkernel_info_request. But keeping thekernel_info_requesthere will never be wrong.