Sessions and streams¶
fastsandbox.Session
¶
A session that keeps a sandbox running while it is held.
Use it as an async context manager, or call release(); the sandbox stops
about 30 s after the last session closes.
fastsandbox.Interactive
¶
An interactive command or agent session.
Write its standard input with write and close_stdin, read its output
with async for chunk in session, resize its terminal, wait for its exit
code; or collect everything at once. As an async context manager, it
closes the standard input on exit.
write
async
¶
Writes data (UTF-8 for a string) to the standard input.
wait
async
¶
Waits for the exit code, for at most timeout seconds.
collect
async
¶
collect(stdin: bytes | str = b'', exit_timeout: float = 10.0) -> AttachOutput
Writes stdin, closes it, and reads everything until the exit.
Only possible before the session is used piece by piece.
fastsandbox.Stream
¶
A stream of the daemon: daemon events, prompts, creation or pull progress, export chunks.
The chunks of an image export (client.images.export_stream) are a Stream[bytes].
Iterate it with async for; leave early with aclose() or by using it as
an async context manager, which closes its connection to the daemon.
fastsandbox.SshTunnel
¶
A byte tunnel to the SSH server of a sandbox.
The server accepts any user, root included, without credentials: whoever
holds the tunnel is root in the sandbox. Keep it to trusted code.