pysabelle.server package

Submodules

pysabelle.server.exceptions module

Exceptions raised during server process management.

exception pysabelle.server.exceptions.IsabelleServerError[source]

Bases: IsabelleError

Base class for errors raised by server process management.

exception pysabelle.server.exceptions.ServerStartupTimeout[source]

Bases: IsabelleServerError

The server did not emit its ready line within the configured timeout.

exception pysabelle.server.exceptions.ServerAlreadyRunning[source]

Bases: IsabelleServerError

A server with the same name is already running.

exception pysabelle.server.exceptions.ServerNotRunning[source]

Bases: IsabelleServerError

An operation requiring a live server was invoked with none active.

pysabelle.server.models module

Data models for server information.

class pysabelle.server.models.ServerInfo(name, host, port, password)[source]

Bases: object

Connection information for a running Isabelle server.

Variables:
  • name – Server name (as given with -n).

  • host – Hostname or IP address the server is listening on.

  • port – TCP port number.

  • password – Password required for the initial handshake.

Parameters:
  • name (str)

  • host (str)

  • port (int)

  • password (str)

name: str
host: str
port: int
password: str

pysabelle.server.server_process module

Management of Isabelle server subprocesses.

pysabelle.server.server_process.list_servers(isabelle_bin='isabelle', env=None)[source]

List all currently running Isabelle servers (isabelle server -l).

Parameters:
  • isabelle_bin (str) – Path or name of the isabelle executable.

  • env (dict[str, str] | None) – Environment for the subprocess (default: inherit). It determines $ISABELLE_HOME_USER and hence the servers.db that is consulted.

Return type:

list[ServerInfo]

Returns:

List of ServerInfo objects for each running server.

Raises:

IsabelleServerError – If the executable is missing or the command fails.

pysabelle.server.server_process.is_server_running(name, isabelle_bin='isabelle', env=None)[source]

Check whether a server with the given name is currently running.

Parameters:
  • name (str) – Server name.

  • isabelle_bin (str) – Path or name of the isabelle executable.

  • env (dict[str, str] | None) – Environment for the subprocess (see list_servers()).

Return type:

bool

Returns:

True if a server with that name exists.

class pysabelle.server.server_process.BaseIsabelleServer[source]

Bases: ABC

Abstract interface for Isabelle server lifecycle managers.

abstract property is_running: bool

True if the server is currently active.

abstract property info: ServerInfo

Connection details for the running server.

Raises:

ServerNotRunning – If the server has not been started yet.

abstractmethod start()[source]

Start (or attach to) the server and return its connection info.

Return type:

ServerInfo

abstractmethod stop()[source]

Stop (or detach from) the server.

Return type:

None

class pysabelle.server.server_process.IsabelleServerProcess(name='isabelle', port=None, log_file=None, assume_existing=False, force_start=False, isabelle_bin='isabelle', startup_timeout=30.0, env=None)[source]

Bases: BaseIsabelleServer

Manages an isabelle server subprocess.

This class can either spawn a new server, attach to an existing one, or replace a running server (force_start=True). It implements the context manager protocol.

Parameters:
  • name (str) – Server name (passed as -n).

  • port (int | None) – Optional specific port; if None, the OS assigns one.

  • log_file (str | Path | None) – Optional path to write server logs.

  • assume_existing (bool) – If True, do not start a new process; instead, attach to an already running server with the given name.

  • force_start (bool) – If True and a server with the same name is already running, stop it first and then start a fresh one.

  • isabelle_bin (str) – Path or name of the isabelle executable.

  • startup_timeout (float) – Maximum seconds to wait for the server to become ready.

  • env (dict[str, str] | None) – Environment for every isabelle subprocess (spawn, -l, -x); None inherits os.environ. Use it e.g. to select a different ISABELLE_HOME_USER.

Raises:

ValueError – If both assume_existing and force_start are True.

property is_running: bool

Check if the server process is still alive (by asking isabelle server -l).

property info: ServerInfo

Connection information for the managed server.

Raises:

ServerNotRunning – If start() has not been called yet.

start()[source]

Start or attach to the server.

Behaviour depends on the constructor parameters: - assume_existing=True → attach to an existing server. - force_start=True → stop any existing server and start a new one. - otherwise → start a new server only if none is running.

Return type:

ServerInfo

Returns:

Connection information of the server.

Raises:
stop()[source]

Stop the server if we own it, otherwise just detach.

Return type:

None

Module contents

Server process management: starting, attaching, stopping Isabelle servers.

This package provides tools to control the lifecycle of isabelle server processes and to obtain connection information for running servers.