Long-running work¶
sb.run() waits until the command finishes. The default timeout is 120 seconds; the ceiling is 24 hours. The SDK talks to POST /v1/machines/{id}/execs under the hood, so a proxy cannot kill the job by dropping the HTTP request.
from sistemo import Sandbox
with Sandbox(stack="python") as sb:
r = sb.run("pip install -r requirements.txt && pytest", timeout=3600)
print(r.exit_code, r.stdout)
timeout is enforced inside the machine. When it fires the process is killed (exit 124).
cmd & inside run() does not detach. The job is the process; backgrounding inside the script is how you lose it.
Stream or reconnect¶
If you need logs as they happen, or to survive a client crash, use the same job with a handle:
job = sb.start("npm ci && npm run build", timeout=3600, exec_id="build-1")
for chunk in job.stream():
print(chunk, end="")
print(job.wait().exit_code)
# later
job = sb.job("build-1")
REST: POST /v1/machines/{id}/execs (you mint exec_id), then GET status / output, DELETE to cancel. See Exec.