Command execution

async pglift.cmd.asyncio_run(args: Sequence[str], *, input: str | None = None, capture_output: bool = True, timeout: float | None = None, check: bool = False, log_stdout: bool = False, **kwargs: Any) CompletedProcess
pglift.cmd.asyncio_start_program(cmd: Sequence[str], pidfile: Path | None, *, timeout: float = 1, env: Mapping[str, str] | None = None, capture_output: bool = True) AsyncIterator[Process]

Start program described by ‘cmd’, in the background, and possibly store its PID in ‘pidfile’.

Raises:
  • SystemError – if the program is already running.

  • CommandError – in case program execution terminates after timeout.

When used as a context manager, any exception raised within the block will trigger program termination at exit. This can be used to perform sanity checks shortly after program startup.

pglift.cmd.terminate_program(pidfile: Path) None

Terminate program matching PID in ‘pidfile’.

Upon successful termination, the ‘pidfile’ is removed. No-op if no process matching PID from ‘pidfile’ is running.

pglift.cmd.status_program(pidfile: Path) Status

Return the status of a program which PID is in ‘pidfile’.

Raises:
  • SystemError – if the program is already running.

  • CommandError – in case program execution terminates after timeout.