Construct a kernel object.
Readonly
handleReadonly
serverThe server settings for the kernel.
A signal emitted for any kernel message.
This signal is emitted when a message is received, before it is handled asynchronously.
This message is emitted when a message is queued for sending (either in the websocket buffer, or our own pending message buffer). The message may actually be sent across the wire at a later time.
The message emitted in this signal should not be modified in any way.
The client unique id.
The current connection status of the kernel connection.
A signal emitted when the kernel status changes.
Whether the kernel connection has pending input.
This is a guard to avoid deadlock is the user asks input as second time before submitting his first input
Whether the kernel connection has pending input.
This is a guard to avoid deadlock is the user asks input as second time before submitting his first input
The id of the server-side kernel.
The cached kernel info.
A promise that resolves to the kernel info.
A signal emitted for iopub kernel messages.
This signal is emitted after the iopub message is handled asynchronously.
Test whether the kernel has been disposed.
The name of the server-side kernel.
The kernel spec.
A promise that resolves to the kernel spec.
The subshell ID.
Set the subshell ID.
Check if this kernel supports JEP 91 kernel subshells.
A signal emitted for unhandled kernel message.
This signal is emitted for a message that was not handled. It is emitted during the asynchronous message handling code.
The client username.
Clone the current kernel with a new clientId.
Interrupt a kernel.
Uses the Jupyter Server API.
The promise is fulfilled on a valid response and rejected otherwise.
It is assumed that the API call does not mutate the kernel id or name.
The promise will be rejected if the kernel status is Dead
or if the
request fails or the response is invalid.
Register a comm target handler.
The name of the comm target.
The callback invoked for a comm open message.
A disposable used to unregister the comm target.
Only one comm target can be registered to a target name at a time, an
existing callback for the same target name will be overridden. A registered
comm target handler will take precedence over a comm which specifies a
target_module
.
If the callback returns a promise, kernel message processing will pause until the returned promise is fulfilled.
Register an IOPub message hook.
The callback invoked for the message.
The IOPub hook system allows you to preempt the handlers for IOPub messages that are responses to a given message id.
The most recently registered hook is run first. A hook can return a boolean or a promise to a boolean, in which case all kernel message processing pauses until the promise is fulfilled. If a hook return value resolves to false, any later hooks will not run and the function will return a promise resolving to false. If a hook throws an error, the error is logged to the console and the next hook is run. If a hook is registered during the hook processing, it will not run until the next message. If a hook is removed during the hook processing, it will be deactivated immediately.
See also [[IFuture.registerMessageHook]].
Remove a comm target handler.
The name of the comm target to remove.
Remove an IOPub message hook.
The callback invoked for the message.
Send a comm_info_request
message.
Fulfills with the comm_info_reply
content when the shell reply is
received and validated.
Send a complete_request
message.
See Messaging in Jupyter.
Fulfills with the complete_reply
content when the shell reply is
received and validated.
Send a create_subshell_request
message.
Send a delete_subshell_request
message.
Send an execute_request
message.
See Messaging in Jupyter.
Future onReply
is called with the execute_reply
content when the
shell reply is received and validated. The future will resolve when
this message is received and the idle
iopub status is received.
The future will also be disposed at this point unless disposeOnDone
is specified and false
, in which case it is up to the caller to dispose
of the future.
See also: [[IExecuteReply]]
Optional
allow_stdin?: booleanWhether to allow stdin requests.
The default is true
.
The code to execute.
Optional
silent?: booleanWhether to execute the code as quietly as possible.
The default is false
.
Optional
stop_on_error?: booleanWhether to the abort execution queue on an error.
The default is false
.
Optional
store_history?: booleanWhether to store history of the execution.
The default true
if silent is False.
It is forced to false
if silent is true
.
Optional
user_expressions?: JSONObjectA mapping of names to expressions to be evaluated in the kernel's interactive namespace.
Optional
metadata: JSONObjectSend a history_request
message.
See Messaging in Jupyter.
Fulfills with the history_reply
content when the shell reply is
received and validated.
Send an inspect_request
message.
See Messaging in Jupyter.
Fulfills with the inspect_reply
content when the shell reply is
received and validated.
Send an is_complete_request
message.
See Messaging in Jupyter.
Fulfills with the is_complete_response
content when the shell reply is
received and validated.
Send a kernel_info_request
message.
See Messaging in Jupyter.
Fulfills with the kernel_info_response
content when the shell reply is
received and validated.
Send a list_subshell_request
message.
Request a kernel restart.
Uses the Jupyter Server API and validates the response model.
Any existing Future or Comm objects are cleared once the kernel has actually be restarted.
The promise is fulfilled on a valid server response (after the kernel restarts) and rejected otherwise.
It is assumed that the API call does not mutate the kernel id or name.
The promise will be rejected if the request fails or the response is invalid.
Send a control message to the kernel.
Send a message to the kernel's control channel, yielding a future object for accepting replies.
If expectReply
is given and true
, the future is disposed when both a
control reply and an idle status message are received. If expectReply
is not given or is false
, the future is resolved when an idle status
message is received.
If disposeOnDone
is not given or is true
, the Future is disposed at this point.
If disposeOnDone
is given and false
, it is up to the caller to dispose of the Future.
All replies are validated as valid kernel messages.
If the kernel status is dead
, this will throw an error.
Send a shell message to the kernel.
Send a message to the kernel's shell channel, yielding a future object for accepting replies.
If expectReply
is given and true
, the future is disposed when both a
shell reply and an idle status message are received. If expectReply
is not given or is false
, the future is resolved when an idle status
message is received.
If disposeOnDone
is not given or is true
, the Future is disposed at this point.
If disposeOnDone
is given and false
, it is up to the caller to dispose of the Future.
All replies are validated as valid kernel messages.
If the kernel status is dead
, this will throw an error.
Shutdown a kernel.
Uses the Jupyter Server API.
The promise is fulfilled on a valid response and rejected otherwise.
On a valid response, disposes this kernel connection.
If the kernel is already dead
, disposes this kernel connection without
a server request.
Implementation of the Kernel object.
Notes
Messages from the server are handled in the order they were received and asynchronously. Any message handler can return a promise, and message handling will pause until the promise is fulfilled.