Documentation Index
Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
Use this file to discover all available pages before exploring further.
Help us improve CoreWeave documentation. Take the docs survey.
Execute commands inside a sandbox and capture output.
Documentation Index
Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
Use this file to discover all available pages before exploring further.
# Basic command
sandbox.exec(["echo", "Hello"]).result()
# Raise SandboxExecutionError if command returns non-zero exit code
sandbox.exec(["ls", "/nonexistent"], check=True).result()
# Raise SandboxTimeoutError if command exceeds timeout
sandbox.exec(["sleep", "60"], timeout_seconds=5).result()
# Run in a specific directory
sandbox.exec(["ls"], cwd="/app").result()
import cwsandbox
# exec() returns a Process immediately without waiting for the command to finish
p1 = sandbox.exec(["sleep", "1"])
p2 = sandbox.exec(["sleep", "1"])
p3 = sandbox.exec(["sleep", "1"])
# Call .result() when you need the output - ~1 second total, not 3
cwsandbox.result([p1, p2, p3])
Was this page helpful?