node_id to select the saved state.
See Tree stores for the storage contract.
Save work, close the store, and reopen it
This program writes/saved.txt, closes the database, then resumes the same session.
It prints saved. Configure a connection as described in Connection sources.
- Sync
- Async
session_id="demo", and access to the same ConTree server. It does not
need the original image= argument. An unknown session ID without an image raises
ValueError.
If a store already contains that session ID, the selected saved image takes precedence
over image=. Use a new session ID to start from a different base image.
Snapshots are lightweight and can save work after every command, but each one
stops the running VM. If files have not changed, the image UUID can stay the same.
Store history still identifies each checkpoint. For automatic saving after each
command, see Save after every command.
Choose what to retain
Reopening SQLite restores references to server images. It does not restore images
that were deleted, nor restart processes from an earlier operation.
Advanced: resource ownership
Usewith for sync clients and stores; use async with for async versions.
The sandbox closes its own client and session. It does not close supplied
storage or other application-owned components. See Advanced: assemble a sandbox yourself for
explicit construction and cleanup.
Sharing a store is supported: each session_id has separate history.
A command with a nonzero exit code can still produce a saved image. Inspect the
result before deciding whether to continue or roll back. See Handle failures and unexpected state
and Branch, switch, and roll back.
Resume a selected node
Save the entry ID returned bysnapshot() or commit_result(). Pass it as
node_id= to create_sandbox_session, ContreeSession, or ContreeAsyncSession.
The Store does not remember a shared current position. Two clients can resume the
same node and create independent continuations. Local branch names do not survive
reopening; retain node IDs when your application needs named checkpoints.