def METHOD_NAME(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