class_docstr: Monitor and autorestart a kernel.
code: def poll(self):
      if self.debug:
          self.log.debug("Polling kernel...")
      if not self.kernel_manager.is_alive():
          if self._restarting:
              self._restart_count += 1
          else:
              self._restart_count = 1
  
          if self._restart_count >= self.restart_limit:
              self.log.warning("KernelRestarter: restart failed")
              self._fire_callbacks("dead")
              self._restarting = False
              self._restart_count = 0
              self.stop()
          else:
              newports = (
                  self.random_ports_until_alive
                  and self._initial_startup
              )
              self.log.info(
                  "KernelRestarter: restarting kernel (%i/%i), %s random ports",
                  self._restart_count,
                  self.restart_limit,
                  "new" if newports else "keep",
              )
              self._fire_callbacks("restart")
              self.kernel_manager.restart_kernel(
                  now=True, newports=newports
              )
              self._restarting = True
      else:
          if self._initial_startup:
              self._initial_startup = False
          if self._restarting:
              self.log.debug(
                  "KernelRestarter: restart apparently succeeded"
              )
          self._restarting = False
  
file_path: catboost/contrib/python/jupyter-client/py2/jupyter_client/restarter.py
imports: from traitlets.config.configurable import LoggingConfigurable
  from traitlets import Instance, Float, Dict, Bool, Integer
label_desc: Use image node_id 7 for calling the KernelRestarter obj's underlying member method code with example usage: obj.poll() without return types