libvt.aio — POSIX PTY¶
POSIX pseudo-terminal subprocess adapter exported from libvt.aio.
-
class libvt.aio.PtySession¶class libvt.aio.PtySession¶
Async POSIX PTY subprocess session over
Terminal.Outbound bytes from
send(),send_event(),send_key(),paste(), and synchronous terminal query auto-replies share a single bounded FIFO queue drained vialoop.add_writer, paired withdrain()for high-water backpressure.
-
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, encoding='utf-8', record_events=False, sync_timeout=1.0, write_high_water=None, max_write_buffer=16777216)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, encoding='utf-8', record_events=False, sync_timeout=1.0, write_high_water=None, max_write_buffer=16777216) Spawn argv on a POSIX PTY driven by
Terminal.- Parameters:
argv (
collections.abc.Sequence[str]) – Command and arguments executed viaos.execvp.rows (
int) – Initial PTY height in rows (1..65535).cols (
int) – Initial PTY width in columns (1..65535).scrollback (
int) – Primary-screen scrollback line capacity (>= 0).env (
collections.abc.Mapping[str,str] |None) – Environment variables passed to the child process (defaults toos.environwithTERM=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 theTIOCSCTTYpre-exec trampoline.profile (
Profile) – Terminal compatibility profile.policy (
Policy) – Host security and query policy.limits (
Limits) – Parser and state resource ceilings.encoding (
ParserEncoding) – Initial byte encoding for child output ("utf-8"or"latin-1").record_events (
bool) – Retain events from the first read forsession.terminal.drain_events().sync_timeout (
float) – Watchdog timeout in seconds before expiring stalled?2026frames.write_high_water (
int|None) – High-water mark in bytes for outbound PTY writes (defaults tomin(65_536, max_write_buffer)).max_write_buffer (
int) – Maximum outbound bytes queued beforePtySession.send()raisesBufferError.
- Yields:
PtySession – Active session connected to the child process and master PTY fd.
- Raises:
NotImplementedError– On platforms lacking POSIXpty.openpty()(Windows).TypeError– If argv is a bare string. Use[executable]for one command.ValueError– If argv, dimensions, tty_mode, encoding, sync_timeout, or buffer sizes are invalid.OSError– If PTY allocation orexecvpfails.
- Return type: