Skip to main content
Every capsule moves through a defined set of states from creation to destruction. Understanding those states lets you build reliable workflows: pausing idle capsules to save resources, resuming them instantly when needed, and cleaning up with confidence.

Lifecycle states

When you pause a capsule, Wrenn writes the full VM state — memory, processes, open files — to disk as a snapshot. Resuming restores that snapshot, so the capsule comes back exactly as you left it.

Waiting for a capsule to be ready

After creating a capsule without wait=True, call wait_ready() to block until it reaches running status:
wait_ready raises TimeoutError if the capsule does not reach running within timeout seconds. It raises RuntimeError if the capsule enters error, stopped, or paused state while waiting.

Checking status

Pausing a capsule

Pausing snapshots the running VM to disk and frees the host CPU and memory. The capsule’s filesystem and process state are preserved exactly.

Resuming a capsule

Resume restores the snapshot and brings the capsule back to running. Memory, processes, and open file descriptors are all restored.
Capsule.connect() also resumes a paused capsule automatically:

Destroying a capsule

Destroying a capsule permanently deletes the VM and all data on its filesystem.
Destruction is irreversible. Create a snapshot first if you need to preserve the capsule’s state as a reusable template.

Inactivity timeout and ping

When you create a capsule with a timeout value, the capsule is automatically paused after that many seconds of inactivity. An activity is any exec or ping call. Call ping() to reset the inactivity timer without executing a command:
Set timeout=0 to disable auto-pause entirely. Use this for capsules that must stay running regardless of activity.

Full lifecycle example