Skip to main content
Use create() when your process owns a new desktop. Use attach() when another process owns an existing desktop.

Create an owned desktop

The context waits for daemon readiness. It terminates the created Sandbox on exit. Set wait=False when you need to do other work before readiness:

Attach without taking ownership

Pass exactly one selector. You can use sandbox_id, name, or run_id for a Modal-backed attachment.
detach() closes the daemon connection and releases the local Modal handle. It does not terminate the attached Sandbox.
Call terminate() on an attached desktop only when your process has authority to stop its owner’s Sandbox.

Acquire a named desktop

Use attach_or_create() when a name is your allocation key:
The SDK attaches to a compatible live Sandbox with that app-scoped name. It creates one if none exists. The context terminates only a Sandbox that this call created. An existing named Sandbox must match the expected configuration tags. Use attach(name=...) when you intentionally connect to a legacy target.

Use native async lifecycle methods

The async lifecycle methods are async context managers:
Do not await AsyncComputerSandbox.create() directly. Enter the returned context manager with async with.

Lifecycle summary