0.5.4

Sandbox Uptime

Check how long a sandbox has been running.

sandbox.uptime() -> float

Returns

Returns the sandbox uptime in seconds as a float value.

Examples

Basic Example

from concave import Sandbox import time sbx = Sandbox.create() # Wait a bit time.sleep(2) # Check uptime uptime_seconds = sbx.uptime() print(f"Sandbox has been running for {uptime_seconds:.2f} seconds") sbx.delete()

Clean Up Old Sandboxes

from concave import Sandbox sandboxes = Sandbox.list() for sbx in sandboxes: uptime_hours = sbx.uptime() / 3600 if uptime_hours > 1.0: print(f"Deleting old sandbox {sbx.id}") sbx.delete()

Exceptions

SandboxNotFoundErrorException

Raised when the sandbox no longer exists.

SandboxTimeoutErrorException

Raised when the uptime request times out (5 second timeout).

Error Handling

from concave import ( Sandbox, SandboxNotFoundError, SandboxTimeoutError ) sbx = Sandbox.create() try: uptime_seconds = sbx.uptime() print(f"Sandbox uptime: {uptime_seconds:.2f} seconds") except SandboxNotFoundError: print("Sandbox no longer exists") except SandboxTimeoutError: print("Request timed out") finally: sbx.delete()