(self)
| 73 | self.process.start() |
| 74 | |
| 75 | def terminate(self) -> None: |
| 76 | if self.process.exitcode is None: # Process is still running |
| 77 | assert self.process.pid is not None |
| 78 | if os.name == "nt": # pragma: py-not-win32 |
| 79 | # Windows doesn't support SIGTERM. |
| 80 | # So send SIGBREAK, and then in process raise SIGTERM. |
| 81 | os.kill(self.process.pid, signal.CTRL_BREAK_EVENT) # type: ignore[attr-defined] |
| 82 | else: |
| 83 | os.kill(self.process.pid, signal.SIGTERM) |
| 84 | logger.info(f"Terminated child process [{self.process.pid}]") |
| 85 | |
| 86 | self.parent_conn.close() |
| 87 | self.child_conn.close() |
| 88 | |
| 89 | def kill(self) -> None: |
| 90 | # In Windows, the method will call `TerminateProcess` to kill the process. |
no test coverage detected