ddp_utils.browser.backends.native.session¶
import ddp_utils.browser.backends.native.session
Owned session lifecycle for a native system-browser process.
- class ddp_utils.browser.backends.native.session.NativeBrowserSession(*, descriptor: BackendDescriptor, process: Popen[Any], info: NativeProcessInfo, controller: NativeProcessController, close_timeout: float = 5.0, force_on_close: bool = True)¶
Bases:
objectOwn one native browser process without claiming automation features.
Parameters
Name
Type
Description
descriptor
Immutable native backend descriptor.
process
Popen[Any]
Owned
Popenobject.info
Immutable launch metadata.
controller
Process-tree state and termination controller.
close_timeout
float
Grace period used during close.
force_on_close
bool
Kill surviving processes after the grace period.
Examples
Use native mode as a deterministic context manager:
with session: assert session.is_running()
Initialize process ownership and close policy.
Parameters
Name
Type
Description
descriptor
Immutable native backend descriptor.
process
Popen[Any]
Owned
Popenobject.info
Immutable launch metadata.
controller
Process-tree state and termination controller.
close_timeout
float
Grace period used during close.
force_on_close
bool
Kill survivors after the grace period.
Examples
Construct sessions through
NativeBrowserBackend.start:session = backend.start(config)
- property descriptor: BackendDescriptor¶
Return the immutable native backend descriptor.
Returns
Descriptor advertising only native process capability.
Examples
Confirm that DOM automation is not advertised:
assert not session.descriptor.supports("dom")
- property native: NativeProcessInfo¶
Return immutable native process metadata.
Returns
Process identifier, executable, command, and launch time.
Examples
Read the exact owned process identifier:
pid = session.native.pid
- property closed: bool¶
Return whether this session has completed its close operation.
Returns
Trueafter successful or previously completed close.Examples
Treat repeated close calls as idempotent:
session.close() assert session.closed
- is_running() bool¶
Return whether the owned browser process remains alive.
Returns
Type
Description
bool
Trueonly while the process controller observes a live process.Examples
Wait for a user-controlled browser to exit:
while session.is_running(): poll_business_state()
- close() None¶
Release the complete owned process tree exactly once.
Raises
Exception
Description
Processes remain alive after the configured termination policy.
Examples
Close explicitly outside a context manager:
session.close()