ddp_utils.browser.backends.native.process

import ddp_utils.browser.backends.native.process

Process-state and process-tree termination for native browser sessions.

class ddp_utils.browser.backends.native.process.NativeProcessController

Bases: object

Control one owned browser process tree using lazy psutil access.

Examples

Check whether a native session process remains alive:

running = NativeProcessController().is_running(session.native.pid)
is_running(pid: int) → bool

Return whether a process exists and is not a zombie.

Parameters

Name

Type

Description

pid

int

Operating-system process identifier.

Returns

Type

Description

bool

True for a live non-zombie process; otherwise False.

Examples

Poll an owned browser process:

if controller.is_running(info.pid):
    print("browser is running")
terminate(pid: int, *, timeout: float, force: bool) → bool

Terminate an owned process tree and optionally force survivors.

Parameters

Name

Type

Description

pid

int

Root process identifier.

timeout

float

Grace period in seconds after terminate signals.

force

bool

Kill surviving processes after the grace period.

Returns

Type

Description

bool

True when the complete observed process tree is no longer alive.

Examples

Close a browser and force only after its grace period:

closed = controller.terminate(info.pid, timeout=5, force=True)