libvt.aio

Transport-only asyncio stream and POSIX PTY adapters over Terminal.

class libvt.aio.AsyncTerminalStream
class libvt.aio.AsyncTerminalStream

Bases: object

Drive a sans-I/O Terminal from asyncio streams.

Coalesces frame wakeups across DEC mode ?2026 synchronized-output batches (bounded by sync_timeout using generation-safe expiry) and automatically flushes drain_replies() when a StreamWriter is attached.

class libvt.aio.PtySession
class libvt.aio.PtySession

Bases: object

Async POSIX pseudo-terminal subprocess session backed by Terminal.

class libvt.aio.ReplyWriter
class libvt.aio.ReplyWriter

Bases: Protocol

Structural writer protocol satisfied by asyncio.StreamWriter.

libvt.aio.open_pty(argv, *, rows=24, cols=80, scrollback=2000, env=None, cwd=None, tty_mode='cooked', python_executable=None, profile=DEFAULT_PROFILE, policy=DEFAULT_POLICY, limits=DEFAULT_LIMITS, sync_timeout=1.0)
function[source]
function[source]
libvt.aio.open_pty(argv, *, rows=24, cols=80, scrollback=2000, env=None, cwd=None, tty_mode='cooked', python_executable=None, profile=DEFAULT_PROFILE, policy=DEFAULT_POLICY, limits=DEFAULT_LIMITS, sync_timeout=1.0)

Spawn argv with a controlling POSIX PTY driven by Terminal.

Parameters:
  • argv (collections.abc.Sequence[str]) – Command and arguments executed via os.execvp.

  • rows (int) – Initial PTY height in rows.

  • cols (int) – Initial PTY width in columns.

  • scrollback (int) – Primary-screen scrollback line capacity.

  • env (collections.abc.Mapping[str, str] | None) – Environment variables passed to the child process (defaults to os.environ with TERM=xterm-256color).

  • cwd (str | os.PathLike[str] | None) – Working directory for the child process.

  • tty_mode (TtyMode) – Initial slave terminal mode ("cooked", "cbreak", or "raw").

  • python_executable (str | os.PathLike[str] | None) – Python interpreter used for the TIOCSCTTY pre-exec trampoline.

  • profile (Profile) – Terminal compatibility profile.

  • policy (Policy) – Host security and query policy.

  • limits (Limits) – Parser and state resource ceilings.

  • sync_timeout (float) – Watchdog timeout in seconds before expiring stalled ?2026 frames.

Yields:

PtySession – Active session connected to the child process and master PTY fd.

Raises:
  • NotImplementedError – On platforms lacking POSIX pty.openpty() (Windows).

  • ValueError – If argv is empty or tty_mode is invalid.

  • OSError – If PTY allocation or execvp fails.

Return type:

AsyncGenerator[PtySession]