class_docstr: Manages a single kernel in a subprocess on this host.
  
  This version starts kernels with Popen.
class_docstr_tok: ["Manages","a","single","kernel","in","a","subprocess","on","this","host",".","This","version","starts","kernels","with","Popen","."]
docstr: Restarts a kernel with the arguments that were used to launch it.
  
  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.
  
  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.
docstr_tok: ["Restarts","a","kernel","with","the","arguments","that","were","used","to","launch","it",".","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",".","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","."]
code: def restart_kernel(self, now=False, newports=False, **kw):
      """Restarts a kernel with the arguments that were used to launch it.
  
      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.
  
      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.
      """
      if self._launch_args is None:
          raise RuntimeError(
              "Cannot restart the kernel. "
              "No previous call to 'start_kernel'."
          )
      else:
          # Stop currently running kernel.
          self.shutdown_kernel(now=now, restart=True)
  
          if newports:
              self.cleanup_random_ports()
  
          # Start new kernel.
          self._launch_args.update(kw)
          self.start_kernel(**self._launch_args)
  
imports: from __future__ import absolute_import
  from contextlib import contextmanager
  import os
  import re
  import signal
  import sys
  import time
  import warnings
  import zmq
  from ipython_genutils.importstring import import_item
  from .localinterfaces import is_local_ip, local_ips
  from traitlets import Any, Float, Instance, Unicode, List, Bool, Type, DottedObjectName
  from jupyter_client import launch_kernel, kernelspec
  from .connect import ConnectionFileMixin
  from .managerabc import KernelManagerABC
label_desc: Use image node_id 25 for calling the KernelManager obj's underlying member method code with example usage: obj.restart_kernel(now, newports) without return types