Skip to content

Commit 97158dd

Browse files
committed
added notes about sync vs async devbox state behaviour
1 parent 18a10ce commit 97158dd

5 files changed

Lines changed: 59 additions & 111 deletions

File tree

README-SDK.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ devbox.await_suspended()
356356
devbox.shutdown()
357357
```
358358

359+
> **State-waiting behavior:** In the synchronous SDK, `DevboxOps.from_id()` and `Devbox.resume()` block until the devbox reaches the `running` state, and `Devbox.suspend()` blocks until the devbox is `suspended`. The async counterparts (`AsyncDevboxOps.from_id()`, `AsyncDevbox.resume()`, `AsyncDevbox.suspend()`) return immediately; call `await_running()` / `await_suspended()` explicitly if you need to wait for the state transition.
360+
359361
#### Context Manager Support
360362

361363
Devboxes support context managers for automatic cleanup:

src/runloop_api_client/sdk/async_.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ async def create_from_snapshot(
130130
def from_id(self, devbox_id: str) -> AsyncDevbox:
131131
"""Attach to an existing devbox by ID.
132132
133+
Returns immediately without waiting for the devbox to reach ``running``
134+
state. Call ``await_running()`` on the returned :class:`AsyncDevbox` if
135+
you need to wait for readiness (contrast with the synchronous SDK, which blocks).
136+
133137
Args:
134138
devbox_id: Existing devbox ID.
135139

src/runloop_api_client/sdk/async_devbox.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ async def suspend(
169169
) -> DevboxView:
170170
"""Suspend the devbox without destroying state.
171171
172+
Returns immediately after issuing the suspend request. Call
173+
:meth:`await_suspended` if you need to wait for the devbox to reach the
174+
``suspended`` state (contrast with the synchronous SDK, which blocks).
175+
172176
Args:
173177
**options: Optional long-running request configuration.
174178
@@ -186,6 +190,10 @@ async def resume(
186190
) -> DevboxView:
187191
"""Resume a suspended devbox.
188192
193+
Returns immediately after issuing the resume request. Call
194+
:meth:`await_running` if you need to wait for the devbox to reach the
195+
``running`` state (contrast with the synchronous SDK, which blocks).
196+
189197
Args:
190198
**options: Optional long-running request configuration.
191199

src/runloop_api_client/sdk/sync.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ def create_from_snapshot(
130130
def from_id(self, devbox_id: str) -> Devbox:
131131
"""Attach to an existing devbox by ID.
132132
133+
Blocks until the devbox reaches ``running`` state so callers can begin
134+
issuing commands immediately.
135+
133136
Args:
134137
devbox_id: Existing devbox ID.
135138

0 commit comments

Comments
 (0)