Kernel Launchers

The kernel provider is responsible for launching the kernel and returning the connection information and kernel manager instance. For those providers choosing to use Popen as their means of launching their kernels, jupyter_kernel_mgmt provides SubprocessKernelLauncher for the ‘tcp’ transport and and SubprocessIPCKernelLauncher for the ‘ipc’ transport (using filesystem sockets).

class jupyter_kernel_mgmt.subproc.launcher.SubprocessKernelLauncher(kernel_cmd, cwd, extra_env=None, ip=None, launch_params=None)

Run a kernel asynchronously in a subprocess.

Parameters
  • kernel_cmd (list of str) – The Popen command template to launch the kernel

  • cwd (str) – The working directory to launch the kernel in

  • extra_env (dict, optional) – Dictionary of environment variables to update the existing environment

  • ip (str, optional) – Set the kernel’s IP address [default localhost]. If the IP address is something other than localhost, then Consoles on other machines will be able to connect to the Kernel, so be careful!

build_popen_kwargs(connection_file)

Build a dictionary of arguments to pass to Popen

files_to_cleanup(connection_file, connection_info)

Find files to be cleaned up after this kernel is finished.

This method is mostly to be overridden for cleaning up IPC sockets.

format_kernel_cmd(connection_file, kernel_resource_dir=None)

Replace templated args (e.g. {connection_file})

async launch()

The main method to launch a kernel.

Returns (connection_info, kernel_manager)

make_connection_file()

Generates a JSON config file, including the selection of random ports.

make_ports()

Randomly select available ports for each of port_names

class jupyter_kernel_mgmt.subproc.launcher.SubprocessIPCKernelLauncher(kernel_cmd, cwd, extra_env=None, ip=None, launch_params=None)

Start a kernel on this machine to listen on IPC (filesystem) sockets

files_to_cleanup(connection_file, connection_info)

Find files to be cleaned up after this kernel is finished.

This method is mostly to be overridden for cleaning up IPC sockets.

make_ports()

Randomly select available ports for each of port_names