connect().
Async
AsyncPtyHandle mirrors the same surface with await and an async context manager.
Methods
Properties
Behaviour notes
wait_for_connectionmeans “was opened”, not “still open”. A short-lived command can open, produce output and finish before you call it; that still returnsTrue. Useis_connectedwhen you specifically need to know whether the stream is open at this instant.wait_for_connectionauto-connects only once. If you never calledconnect()it connects for you. It will not silently re-attach a stream that has already finished, so buffered output is never duplicated.- The output buffer is bounded at 1 MiB. Once full, the oldest bytes are dropped. For a
complete transcript, pass an
on_datacallback and write the chunks yourself, or redirect the program’s output to a file in the runtime. - Disconnecting does not kill the session. The guest session and its scrollback survive,
so you can re-attach later with a fresh handle. Call
kill()to terminate it. - The context manager disconnects on exit, including on exception, so a handle cannot leak a reader thread or an open HTTP response.