manager - starting, stopping, signalling¶
- class jupyter_client.KernelManager(**kwargs)¶
Manages a single kernel in a subprocess on this host.
This version starts kernels with Popen.
- provisioner: Optional[jupyter_client.provisioning.provisioner_base.KernelProvisionerBase] = None¶
The kernel provisioner with which this
KernelManageris communicating. This will generally be a
LocalProvisionerinstance unless the kernelspec indicates otherwise.
Starts a kernel on this host in a separate process.
If random ports (port=0) are being used, this method must be called before the channels are created.
**kw (optional) – keyword arguments that are passed down to build the kernel_cmd and launching the kernel (e.g. Popen kwargs).
Is the kernel process still running?
Interrupts the kernel by sending it a signal.
signal_kernel, this operation is well supported on all platforms.
Sends a signal to the process group of the kernel (this usually includes the kernel and any subprocesses spawned by the kernel).
Note that since only SIGTERM is supported on Windows, this function is only useful on Unix systems.
- client(**kwargs) jupyter_client.client.KernelClient ¶
Create a client configured to connect to our kernel
For the client API, see
Make a blocking client connected to my kernel
Attempts to stop the kernel process cleanly.
This attempts to shutdown the kernels cleanly by:
Sending it a shutdown message over the control channel.
If that fails, the kernel is shutdown forcibly by sending it a signal.
now (bool) – Should the kernel be forcible killed now. This skips the first, nice shutdown attempt.
restart (bool) – Will this kernel be restarted after it is shutdown. When this is True, connection files will not be cleaned up.
Restarts a kernel with the arguments that were used to launch it.
now (bool, optional) –
If True, the kernel is forcefully restarted immediately, without having a chance to do any cleanup action. Otherwise the kernel is given 1s to clean up before a forceful restart is issued.
In all cases the kernel is restarted, the only difference is whether it is given a chance to perform a clean shutdown or not.
newports (bool, optional) – If the old kernel was launched with random ports, this flag decides whether the same ports and connection file will be used again. If False, the same ports and connection file are used. This is the default. If True, new random port numbers are chosen and a new connection file is written. It is still possible that the newly chosen random port numbers happen to be the same as the old ones.
**kw (optional) – Any options specified here will overwrite those used to launch the kernel.
multikernelmanager - controlling multiple kernels¶
- class jupyter_client.MultiKernelManager(**kwargs)¶
A class for managing multiple kernels.
Start a new kernel.
The caller can pick a kernel_id by passing one in as a keyword arg, otherwise one will be generated using new_kernel_id().
The kernel ID for the newly started kernel is returned.
- list_kernel_ids() List[str] ¶
Return a list of the kernel ids of the active kernels.
- get_kernel(kernel_id: str) jupyter_client.manager.KernelManager ¶
Get the single KernelManager object for a kernel by its uuid.
kernel_id (uuid) – The id of the kernel.
- remove_kernel(kernel_id: str) jupyter_client.manager.KernelManager ¶
remove a kernel from our mapping.
Mainly so that a kernel can be removed if it is already dead, without having to call shutdown_kernel.
The kernel object is returned, or None if not found.
Shutdown all kernels.