(self)
| 137 | return '<%s>' % ' '.join(info) |
| 138 | |
| 139 | def _kill(self) -> None: |
| 140 | popen = self._popen |
| 141 | if popen is None: |
| 142 | return |
| 143 | |
| 144 | if self._killed: |
| 145 | return |
| 146 | self._killed = True |
| 147 | |
| 148 | use_killpg = USE_PROCESS_GROUP |
| 149 | if use_killpg: |
| 150 | parent_sid = os.getsid(0) |
| 151 | sid = os.getsid(popen.pid) |
| 152 | use_killpg = (sid != parent_sid) |
| 153 | |
| 154 | if use_killpg: |
| 155 | what = f"{self} process group" |
| 156 | else: |
| 157 | what = f"{self} process" |
| 158 | |
| 159 | print(f"Kill {what}", file=sys.stderr, flush=True) |
| 160 | try: |
| 161 | if use_killpg: |
| 162 | os.killpg(popen.pid, signal.SIGKILL) |
| 163 | else: |
| 164 | popen.kill() |
| 165 | except ProcessLookupError: |
| 166 | # popen.kill(): the process completed, the WorkerThread thread |
| 167 | # read its exit status, but Popen.send_signal() read the returncode |
| 168 | # just before Popen.wait() set returncode. |
| 169 | pass |
| 170 | except OSError as exc: |
| 171 | print_warning(f"Failed to kill {what}: {exc!r}") |
| 172 | |
| 173 | def stop(self) -> None: |
| 174 | # Method called from a different thread to stop this thread |
no test coverage detected