@e2b/python-sdk@2.30.0
Minor Changes
-
7e7e951: Add an object form to the sandbox
lifecycle.onTimeout(on_timeoutin Python)
that controls the snapshot kind taken when a sandbox auto-pauses on timeout, via
keepMemory(keep_memory).onTimeoutnow accepts either the existing bare action ('pause'/'kill') or
the object form. The object form is a discriminated union onaction:
keepMemoryis only accepted alongsideaction: 'pause'— pairing it with
action: 'kill'is a compile-time type error (and is rejected at runtime for
untyped callers). WhenkeepMemoryisfalse, 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 totrue(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_memoryin Python) option topausefor
filesystem-only snapshots.When
keepMemoryisfalse, 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 totrue(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:
WatchHandlenow awaits asynconEvent/onExitcallbacks. A rejecting asynconEventis routed toonExitand stops the watch instead of becoming an unhandled promise rejection that can crash Node, and async callbacks get backpressure/ordering — matchingCommandHandle. - Python (sync):
WatchHandle.get_new_events()andstop()now send a request timeout (default 60s, overridable viarequest_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):
AsyncWatchHandlenow invokeson_exitwhen the stream ends cleanly (withNone) and whenstop()is called, in addition to on error — matching the JS SDK.
- JS: