Handle to a running command with streaming output and auto-reconnect.
Iterable, yielding OutputChunk objects (stdout and stderr interleaved in arrival order). Access .result after iteration to get the full ExecutionResult.
Auto-reconnect behavior:
The auto-reconnect is transparent -- the iterator reconnects and continues yielding chunks without any user intervention. If all reconnect attempts are exhausted, SandboxConnectionError is raised.
Construction modes (controlled by command_id):
command_id="", the default): the constructor
eagerly reads the server's "started" message to populate
command_id and pid before returning.command_id set): skips the started-message
read, since reconnect streams don't emit one.Example:
handle = sandbox.run("make build", timeout=600, wait=False)
for chunk in handle: # auto-reconnects on transient errors print(chunk.data, end="")
result = handle.result print(f"Exit code: {result.exit_code}")