Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Change to process group for better killing of multi-process chrome
- Add argument to Session/Target send_command with_perf to return
timing information about browser write/read.
- Update default chrome from 135.0.7011.0/1418433 to 144.0.7527.0/1544685
Expand Down
2 changes: 2 additions & 0 deletions src/choreographer/browser_async.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Provides the async api: `Browser`, `Tab`."""

# hello, thank you for visiting

from __future__ import annotations

import asyncio
Expand Down
2 changes: 2 additions & 0 deletions src/choreographer/browsers/chromium.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ def get_popen_args(self) -> Mapping[str, Any]:
if isinstance(self._channel, Pipe):
args["stdin"] = self._channel.from_choreo_to_external
args["stdout"] = self._channel.from_external_to_choreo
args["start_new_session"] = True

_logger.debug(f"Returning args: {args}")
return args

Expand Down
29 changes: 23 additions & 6 deletions src/choreographer/utils/_kill.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
from __future__ import annotations

import os
import platform
import subprocess

import logistro

if (_system := platform.system()) != "Windows":
import signal

_logger = logistro.getLogger(__name__)


def kill(process: subprocess.Popen[bytes] | subprocess.Popen[str]) -> None:
if platform.system() == "Windows":
if _system == "Windows":
subprocess.call( # noqa: S603, false positive, input fine
["taskkill", "/F", "/T", "/PID", str(process.pid)], # noqa: S607 windows full path...
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
timeout=6,
)
else:
return

try:
os.killpg(
process.pid,
signal.SIGTERM, # type: ignore[reportPossiblyUnboundVariable]
)
except ProcessLookupError:
process.terminate()
_logger.debug("Called terminate (a light kill).")
_logger.debug("Called terminate (a light kill).")
try:
process.wait(timeout=6)
except subprocess.TimeoutExpired:
_logger.debug("Calling kill (a heavy kill).")
try:
process.wait(timeout=6)
except subprocess.TimeoutExpired:
_logger.debug("Calling kill (a heavy kill).")
os.killpg(
process.pid,
signal.SIGKILL, # type: ignore[reportPossiblyUnboundVariable]
)
except ProcessLookupError:
process.kill()