MCPcopy Create free account
hub / github.com/TheSmallHanCat/flow2api / _kill_pid

Method _kill_pid

src/services/browser_captcha.py:955–972  ·  view source on GitHub ↗
(self, pid: Optional[int], reason: str)

Source from the content-addressed store, hash-verified

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()

Callers 2

_close_browserMethod · 0.95

Calls 1

log_warningMethod · 0.80

Tested by

no test coverage detected