v0.7.2

Resume

Resume a paused sandbox to continue execution from where it was frozen.

sandbox.resume() -> Dict[str, Any]

We preserve all VM state during pause/resume. Execution continues exactly where it left off.

Returns

sandbox_idstr

The ID of the resumed sandbox.

pausedbool

Always False after successful resume operation.

Examples

Basic Pause/Resume

from concave import Sandbox sbx = Sandbox.create() # Set up some state in files sbx.execute("echo '42' > /tmp/x.txt") sbx.execute("echo '100' > /tmp/y.txt") # Pause the sandbox sbx.pause() print("Sandbox paused") # Resume execution result = sbx.resume() print(f"Resumed: paused={result['paused']}") # File system state is preserved output = sbx.execute("echo $(( $(cat /tmp/x.txt) + $(cat /tmp/y.txt) ))") print(output.stdout) # "142" sbx.delete()

Resume with File System State

from concave import Sandbox sbx = Sandbox.create() # Create files and write data sbx.files.write("/tmp/data.txt", "important data") sbx.execute("echo 'more data' >> /tmp/data.txt") # Pause the sandbox sbx.pause() # Resume later sbx.resume() # File system is preserved content = sbx.files.read("/tmp/data.txt") print(content) # "important data\nmore data\n" sbx.delete()

Multiple Pause/Resume Cycles

from concave import Sandbox sbx = Sandbox.create() # Initialize counter in a file sbx.execute("echo '0' > /tmp/counter.txt") for i in range(3): # Increment counter sbx.execute("echo $(( $(cat /tmp/counter.txt) + 1 )) > /tmp/counter.txt") counter = sbx.execute("cat /tmp/counter.txt").stdout.strip() print(f"Counter: {counter}") # Pause between iterations sbx.pause() print(f"Paused after iteration {i+1}") # Resume for next iteration if i < 2: sbx.resume() print(f"Resumed for iteration {i+2}") # Final value sbx.resume() output = sbx.execute("cat /tmp/counter.txt") print(f"Final counter: {output.stdout.strip()}") # "3" sbx.delete()

With Error Handling

from concave import Sandbox, SandboxClientError sbx = Sandbox.create() # Pause first sbx.pause() try: sbx.resume() print("Sandbox resumed successfully") # Try to resume again (will raise error) sbx.resume() except SandboxClientError as e: if "not paused" in str(e): print("Sandbox is not paused, already running") finally: sbx.delete()

Exceptions

SandboxClientErrorException

Raised when the sandbox is not paused (HTTP 409 Conflict).

SandboxNotFoundErrorException

Raised when the sandbox no longer exists or has been deleted.

SandboxUnavailableErrorException

Raised when the sandbox service is unavailable or the VM cannot be resumed.

SandboxTimeoutErrorException

Raised when the resume request times out.