Stop the embed server subprocess.
(self)
| 128 | return False |
| 129 | |
| 130 | def stop(self): |
| 131 | """Stop the embed server subprocess.""" |
| 132 | if self.process: |
| 133 | try: |
| 134 | import signal as _signal |
| 135 | if os.name != "nt": |
| 136 | try: |
| 137 | os.killpg(os.getpgid(self.process.pid), _signal.SIGTERM) |
| 138 | except ProcessLookupError: |
| 139 | self.process.terminate() |
| 140 | else: |
| 141 | self.process.terminate() |
| 142 | try: |
| 143 | self.process.wait(timeout=5) |
| 144 | except subprocess.TimeoutExpired: |
| 145 | try: |
| 146 | os.killpg(os.getpgid(self.process.pid), _signal.SIGKILL) |
| 147 | except Exception: |
| 148 | self.process.kill() |
| 149 | except Exception: |
| 150 | try: |
| 151 | self.process.kill() |
| 152 | except Exception: |
| 153 | pass |
| 154 | finally: |
| 155 | self.process = None |
| 156 | self._started = False |
| 157 | info("Embed server stopped") |
| 158 | |
| 159 | def is_running(self) -> bool: |
| 160 | if self.process is not None and self.process.poll() is None: |
no test coverage detected