Stops the service.
(self)
| 156 | sleep(1) |
| 157 | |
| 158 | def stop(self) -> None: |
| 159 | """Stops the service.""" |
| 160 | if self.log_output not in {PIPE, subprocess.DEVNULL}: |
| 161 | if isinstance(self.log_output, int): |
| 162 | os.close(self.log_output) |
| 163 | elif self.log_output is not None and self._owns_log_output: |
| 164 | self.log_output.close() |
| 165 | if self.process is not None: |
| 166 | try: |
| 167 | if self.process.poll() is None: |
| 168 | try: |
| 169 | self.send_remote_shutdown_command() |
| 170 | except TypeError: |
| 171 | pass |
| 172 | finally: |
| 173 | self._terminate_process() |
| 174 | |
| 175 | def _terminate_process(self) -> None: |
| 176 | """Terminate the child process. |