Sessions manage multiple sandboxes with shared defaults and automatic cleanup: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.
Tutorial for managing multiple CoreWeave sandbox instances using sessions with shared defaults
Sessions manage multiple sandboxes with shared defaults and automatic cleanup: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.
from cwsandbox import Sandbox, SandboxDefaults
defaults = SandboxDefaults(container_image="python:3.11", tags=("my-app",))
with Sandbox.session(defaults) as session:
sb1 = session.sandbox()
sb2 = session.sandbox()
p1 = sb1.exec(["echo", "one"])
p2 = sb2.exec(["echo", "two"])
print(p1.result().stdout, p2.result().stdout)
# All sandboxes cleaned up
Was this page helpful?