Skip to content

testudos.internal.session

testudos.internal.session

Session management: single global session, start_application, current_session.

The session wraps the native C++ engine client (testudos_runner.EngineSession). Only one active session is allowed; start_application() sets it, current_session() returns it.

Session Objects

class Session()

Wraps host/port and holds the native engine session for high-level RPC operations.

engine

@property
def engine() -> _MappedEngine

Return the native-backed engine client (high-level methods, no wire RPC in Python).

resolve_engine_endpoint

def resolve_engine_endpoint(host: str | None = None,
port: int | None = None) -> tuple[str, int]

Return host and port used to connect to the engine.

Applies TESTUDOS_ENGINE_HOST / TESTUDOS_ENGINE_PORT when host or port are omitted. Intended for tests and tooling; normal code uses setup_client(host=…, port=…).

start_application

def start_application(host: str | None = None,
port: int | None = None,
*,
connect_timeout: float = 5.0,
recv_timeout: float = 20.0) -> Session

Connect to the engine and set the global active session.

Raises:

  • TransportError - If connection fails.
  • TestudosError - If the native module is missing.

setup_client

def setup_client(host: str | None = None,
port: int | None = None,
*,
connect_timeout: float = 5.0,
recv_timeout: float = 20.0) -> Session

Connect to the engine and set the global active session (test client setup).

Call this once before using wait_for_object, start_app, stop_app, etc.

current_session

def current_session() -> Session

Return the active session. Raises if none has been set.

Raises:

  • TestudosError - If setup_client() has not been called.