### Navigation

- index
- modules |
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »

# Module: `kernel.manager`

Base class to manage a running kernel

## 1 Class

class `IPython.kernel.manager.``KernelManager`(**kwargs)

  Bases: `IPython.config.configurable.LoggingConfigurable`, `IPython.kernel.connect.ConnectionFileMixin`

  Manages a single kernel in a subprocess on this host.

  This version starts kernels with Popen.

  `add_restart_callback`(callback, event='restart')

    register a callback to be called when a kernel is restarted

  `client`(**kwargs)

    Create a client configured to connect to our kernel

  `format_kernel_cmd`(**kw)

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

  `has_kernel`

    Has a kernel been started that we are managing.

  `interrupt_kernel`()

    Interrupts the kernel by sending it a signal.

    Unlike `signal_kernel`, this operation is well supported on all platforms.

  `is_alive`()

    Is the kernel process still running?

  `remove_restart_callback`(callback, event='restart')

    unregister a callback to be called when a kernel is restarted

  `restart_kernel`(now=False, **kw)

    Restarts a kernel with the arguments that were used to launch it.

    If the old kernel was launched with random ports, the same ports will be used for the new kernel. The same connection file is used again.

    Parameters: | 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. **kw : optional Any options specified here will overwrite those used to launch the kernel.

  `shutdown_kernel`(now=False, restart=False)

    Attempts to the stop the kernel process cleanly.

    This attempts to shutdown the kernels cleanly by:

    1. Sending it a shutdown message over the shell channel.
    2. If that fails, the kernel is shutdown forcibly by sending it a signal.

    Parameters: | 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.

  `signal_kernel`(signum)

    Sends a signal to the kernel.

    Note that since only SIGTERM is supported on Windows, this function is only useful on Unix systems.

  `start_kernel`(**kw)

    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).

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »