MCPcopy Create free account
hub / github.com/microsoft/Webwright / _terminate_pid

Function _terminate_pid

src/webwright/tools/persistent_local_browser.py:183–200  ·  view source on GitHub ↗
(pid: int, kill_timeout: float)

Source from the content-addressed store, hash-verified

181
182
183def _terminate_pid(pid: int, kill_timeout: float) -> str:
184 if pid <= 0 or not _pid_alive(pid):
185 return "not_running"
186 try:
187 os.kill(pid, signal.SIGTERM)
188 except ProcessLookupError:
189 return "already_gone"
190 deadline = time.monotonic() + kill_timeout
191 while time.monotonic() < deadline:
192 if not _pid_alive(pid):
193 return "terminated"
194 time.sleep(0.1)
195 try:
196 os.kill(pid, signal.SIGKILL)
197 except ProcessLookupError:
198 return "already_gone"
199 time.sleep(0.2)
200 return "killed" if not _pid_alive(pid) else "still_alive"
201
202
203def _cmd_release(args: argparse.Namespace) -> int:

Callers 1

_cmd_releaseFunction · 0.85

Calls 1

_pid_aliveFunction · 0.85

Tested by

no test coverage detected