Skip to main content

What You’ll Learn

  • Creating a sandbox with Sandbox.create()
  • Running a shell command with sbx.commands.run()
  • Reading command output via result.stdout and result.exit_code
  • Using the async API with AsyncSandbox (Python)
  • Proper cleanup with try/finally and sbx.kill()

Prerequisites

Code Walkthrough

Import both the synchronous and asynchronous sandbox classes:
Synchronous usage — create a sandbox, run a command, clean up:
Async usage — identical flow using await:
Run both from main():

Expected Output