Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.fermion.app/llms.txt

Use this file to discover all available pages before exploring further.

The is_connected() method provides a quick way to verify whether your current sandbox instance is actively connected to Fermion’s backend infrastructure. This can be useful for checking the session state before running commands, writing files, or performing other operations that require an active connection.

is_connected() -> bool

Description:
Checks if the WebSocket connection to the sandbox is currently active.

Parameters:
None

Returns:
bool : True if the sandbox is connected, False otherwise.

Example

import asyncio
from fermion_sandbox import Sandbox

async def main():
    sandbox = Sandbox(api_key="your-api-key")

    # Check initial connection state
    print(sandbox.is_connected())  # False

    # Create a new sandbox
    await sandbox.create(should_backup_filesystem=False)
    print(sandbox.is_connected())  # True

    # Disconnect from the sandbox
    await sandbox.disconnect()
    print(sandbox.is_connected())  # False

asyncio.run(main())