def stop(self) -> None:
        """
        Stops a subprocess.

        Asks nicely. Waits. Asks less nicely. Repeat until subprocess is dead.

        .. todo::
            cardinal_pythonlib.winservice.ProcessManager._kill: make
            it reliable under Windows
        """
        if not self.running:
            return
        try:
            self.wait(timeout_s=0)
            # If we get here: stopped already
        except subprocess.TimeoutExpired:  # still running
            for kill_level in self.ALL_KILL_LEVELS:
                tried_to_kill = self._terminate(level=kill_level)  # please stop
                if tried_to_kill:
                    try:
                        self.wait(timeout_s=self.kill_timeout_sec)
                        break
                    except subprocess.TimeoutExpired:  # failed to close
                        self.warning("Subprocess didn't stop when asked")
                        pass  # carry on escalating
        self.close_logs()
        self.running = False
def stop ( self ) -> None : if not self . running : return try : self . wait ( timeout_s = 0 ) except subprocess . TimeoutExpired : for kill_level in self . ALL_KILL_LEVELS : tried_to_kill = self . _terminate ( level = kill_level ) if tried_to_kill : try : self . wait ( timeout_s = self . kill_timeout_sec ) break except subprocess . TimeoutExpired : self . warning ( "Subprocess didn't stop when asked" ) pass self . close_logs ( ) self . running = False
Stops a subprocess.

        Asks nicely. Waits. Asks less nicely. Repeat until subprocess is dead.

        .. todo::
            cardinal_pythonlib.winservice.ProcessManager._kill: make
            it reliable under Windows