(self, pid: Optional[int], reason: str)
| 953 | return not self._is_pid_running(pid) |
| 954 | |
| 955 | def _kill_pid(self, pid: Optional[int], reason: str): |
| 956 | if not pid: |
| 957 | return |
| 958 | try: |
| 959 | debug_logger.log_warning( |
| 960 | f"[BrowserCaptcha] Token-{self.token_id} browser process is still alive; force-killing PID={pid}, reason={reason}" |
| 961 | ) |
| 962 | if sys.platform.startswith('win'): |
| 963 | subprocess.run( |
| 964 | ['taskkill', '/PID', str(pid), '/T', '/F'], |
| 965 | capture_output=True, |
| 966 | text=True, |
| 967 | timeout=15, |
| 968 | ) |
| 969 | else: |
| 970 | os.kill(pid, signal.SIGKILL) |
| 971 | except Exception as e: |
| 972 | debug_logger.log_warning(f"[BrowserCaptcha] Token-{self.token_id} failed to kill PID={pid}: {e}") |
| 973 | |
| 974 | async def _cleanup_stale_slot_process(self): |
| 975 | stale_pid = self._read_pid_file() |
no test coverage detected