The spawner.py module#
Summary#
Connection details of a running lane. |
Return the log file used by the lane on |
|
Wait until a port is open, or closed when |
|
Return the process listening on a TCP port. |
|
Build the environment of a lane backend. |
|
Build the command line of a lane backend. |
|
Start a lane backend detached from the current process. |
|
Return a live lane named |
Seconds a new lane gets to bind its HTTP port. |
|
Description#
Spawn lane backends and record them in the registry.
A lane backend is python -m ansys.aedt.mcp --transport http started
detached from the proxy, so it outlives the client window that created it.
Its bearer token travels only through the environment, never through the
command line, which other local users can read.
Module detail#
- spawner.log_path_for(port: int) pathlib.Path#
Return the log file used by the lane on
port.- Parameters:
- port
int HTTP port of the lane.
- port
- Returns:
pathlib.PathLog file path in the state directory.
- spawner.wait_for_port(host: str, port: int, timeout: float, *, open_: bool = True) bool#
Wait until a port is open, or closed when
open_isFalse.
- spawner.backend_command(host: str, port: int, extra_args: list[str]) list[str]#
Build the command line of a lane backend.
- spawner.spawn_backend(host: str, port: int, extra_args: list[str], log_path: pathlib.Path, auth_token: str) subprocess.Popen[bytes]#
Start a lane backend detached from the current process.
- Parameters:
- Returns:
subprocess.PopenHandle of the spawned process.
- spawner.ensure_backend(server_id: str, host: str = DEFAULT_HOST, extra_args: list[str] | None = None, startup_timeout: float = DEFAULT_STARTUP_TIMEOUT) LaneHandle#
Return a live lane named
server_id, spawning it if needed.A free port is reserved in the registry before spawning, so concurrent proxies cannot pick the same one. The spawn itself runs outside the registry lock because it can take many seconds.
- Parameters:
- Returns:
LaneHandleConnection details of the lane.
- Raises:
RuntimeErrorIf a new lane does not start in time.
- spawner.DEFAULT_HOST = '127.0.0.1'#
- spawner.DEFAULT_STARTUP_TIMEOUT = 60.0#
Seconds a new lane gets to bind its HTTP port.
- spawner.BACKEND_MODULE = 'ansys.aedt.mcp'#