Skip to content

@e2b/python-sdk@2.30.0

Choose a tag to compare

@github-actions github-actions released this 25 Jun 18:04
· 7 commits to main since this release
de0c401

Minor Changes

  • 7e7e951: Add an object form to the sandbox lifecycle.onTimeout (on_timeout in Python)
    that controls the snapshot kind taken when a sandbox auto-pauses on timeout, via
    keepMemory (keep_memory).

    onTimeout now accepts either the existing bare action ('pause' / 'kill') or
    the object form. The object form is a discriminated union on action:
    keepMemory is only accepted alongside action: 'pause' — pairing it with
    action: 'kill' is a compile-time type error (and is rejected at runtime for
    untyped callers). When keepMemory is false, a timeout auto-pause drops the
    in-memory state and persists only the filesystem (a filesystem-only snapshot);
    resuming such a sandbox cold-boots (reboots) it from disk, losing running
    processes and open connections. Defaults to true (full memory snapshot). It
    cannot be combined with auto-resume: auto-resume wakes a paused sandbox on
    inbound traffic by restoring its memory snapshot in place, and a filesystem-only
    snapshot has no memory to restore (resuming cold-boots it), so it must be resumed
    explicitly. The bare string form is unchanged.

    # Python
    sbx = Sandbox.create(
        lifecycle={"on_timeout": {"action": "pause", "keep_memory": False}}
    )
    // JS/TS
    const sbx = await Sandbox.create({
      lifecycle: { onTimeout: { action: 'pause', keepMemory: false } },
    })
  • cb5a387: Add a keepMemory (keep_memory in Python) option to pause for
    filesystem-only snapshots.

    When keepMemory is false, pausing drops the in-memory state and captures
    only the filesystem (no memory snapshot); resuming such a snapshot cold-boots
    (reboots) the sandbox from disk, losing running processes and open connections.
    Defaults to true (full memory snapshot), so existing callers are unaffected.

    # Python
    sbx.pause(keep_memory=False)          # filesystem-only snapshot
    // JS/TS
    await sandbox.pause({ keepMemory: false }) // filesystem-only snapshot

Patch Changes

  • de0c401: Fix three filesystem watch handle bugs:
    • JS: WatchHandle now awaits async onEvent/onExit callbacks. A rejecting async onEvent is routed to onExit and stops the watch instead of becoming an unhandled promise rejection that can crash Node, and async callbacks get backpressure/ordering — matching CommandHandle.
    • Python (sync): WatchHandle.get_new_events() and stop() now send a request timeout (default 60s, overridable via request_timeout) so a stalled call can't hang the thread forever, and include the authentication header so the polling/stop calls aren't sent unauthenticated on older envd.
    • Python (async): AsyncWatchHandle now invokes on_exit when the stream ends cleanly (with None) and when stop() is called, in addition to on error — matching the JS SDK.