What You’ll Learn
- Creating a sandbox with
Sandbox.create() - Running a shell command with
sbx.commands.run() - Reading command output via
result.stdoutandresult.exit_code - Using the async API with
AsyncSandbox(Python) - Proper cleanup with
try/finallyandsbx.kill()
Prerequisites
Code Walkthrough
- Python
- TypeScript
Import both the synchronous and asynchronous sandbox classes:Synchronous usage — create a sandbox, run a command, clean up:Async usage — identical flow using Run both from
await:main():