Execution

Async execution management for async commands.

class runloop_api_client.sdk.async_execution.AsyncExecution(client, devbox_id, execution, streaming_group=None)[source]

Manages an asynchronous command execution on a devbox.

Provides coroutines to poll execution state, wait for completion, and terminate the running process. Created by await devbox.cmd.exec_async().

Example

>>> execution = await devbox.cmd.exec_async("python train.py")
>>> state = await execution.get_state()
>>> if state.status == "running":
...     await execution.kill()
>>> result = await execution.result()  # Wait for completion
>>> print(await result.stdout())
property execution_id: str

Return the execution identifier.

Returns:

Unique execution ID

Return type:

str

property devbox_id: str

Return the devbox identifier.

Returns:

Devbox ID where the command is running

Return type:

str

async result(**options)[source]

Wait for completion and return an AsyncExecutionResult.

Parameters:

options (Unpack[LongRequestOptions]) – Optional long-running request configuration

Returns:

Wrapper with exit status and output helpers

Return type:

AsyncExecutionResult

async get_state(**options)[source]

Fetch the latest execution state.

Parameters:

options (Unpack[BaseRequestOptions]) – Optional request configuration

Returns:

Current execution metadata

Return type:

DevboxAsyncExecutionDetailView

async send_std_in(text, **options)[source]

Send nonempty text to an execution started with attach_stdin=True.

Complete each send before the next send or close_std_in. Concurrent calls are not ordered. Client retries can replay input after an ambiguous connection failure; delivery is not guaranteed to be exactly once.

Parameters:
  • text (str) – Text to write to stdin

  • options (Unpack[LongRequestOptions]) – Request configuration forwarded to the generated client

Raises:

RunloopError – If the API reports unsuccessful delivery

Return type:

None

async close_std_in(**options)[source]

Send EOF after all input has been delivered so the execution can finish.

Requires attach_stdin=True. Wait for pending sends before closing. This handle does not serialize calls or guarantee exactly-once delivery.

Parameters:

options (Unpack[LongRequestOptions]) – Request configuration forwarded to the generated client

Raises:

RunloopError – If the API reports unsuccessful delivery

Return type:

None

async kill(**options)[source]

Request termination of the running execution.

Parameters:

options (Unpack[LongRequestOptions]) – Optional long-running request configuration

Return type:

None