manager - starting, stopping, signalling¶
Manages a single kernel in a subprocess on this host.
This version starts kernels with Popen.
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.
Parameters: **kw (optional) – keyword arguments that are passed down to build the kernel_cmd and launching the kernel (e.g. Popen kwargs).
Once the kernel has been started, this is the
subprocess.Popenclass for the kernel process.
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.
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 shell 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.
restart_kernel(now=False, newports=False, **kw)¶
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.
- now (bool, optional) –
multikernelmanager - controlling multiple kernels¶
A class for managing multiple kernels.
This exposes the same methods as
KernelManager, but their first parameter is a kernel ID, a string identifying the kernel instance. Typically these are UUIDs picked by
Start a new kernel.
The caller can pick a kernel_id by passing one in as a keyword arg, otherwise one will be picked using a uuid.
The kernel ID for the newly started kernel is returned.
Return a list of the kernel ids of the active kernels.
Get the single KernelManager object for a kernel by its uuid.
Parameters: kernel_id (uuid) – The id of the kernel.
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.
Shutdown all kernels.