

def restart_kernel(self, now=False):
    'Restarts a kernel with the same arguments that were used to launch\n        it. If the old kernel was launched with random ports, the same ports\n        will be used for the new kernel.\n\n        Parameters\n        ----------\n        now : bool, optional\n          If True, the kernel is forcefully restarted *immediately*, without\n          having a chance to do any cleanup action.  Otherwise the kernel is\n          given 1s to clean up before a forceful restart is issued.\n\n          In all cases the kernel is restarted, the only difference is whether\n          it is given a chance to perform a clean shutdown or not.\n        '
    if (self._launch_args is None):
        raise RuntimeError("Cannot restart the kernel. No previous call to 'start_kernel'.")
    else:
        if self.has_kernel:
            if now:
                self.kill_kernel()
            else:
                self.shutdown_kernel(restart=True)
        self.start_kernel(**self._launch_args)
        if (sys.platform == 'win32'):
            time.sleep(0.2)

dataset/ETHPy150Open ipython/ipython-py3k/IPython/parallel/engine/kernelstarter.py KernelStarter.restart_kernel/original