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:
- property devbox_id: str¶
Return the devbox identifier.
- Returns:
Devbox ID where the command is running
- Return type:
- 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:
- async get_state(**options)[source]¶
Fetch the latest execution state.
- Parameters:
options (
Unpack[BaseRequestOptions]) – Optional request configuration- Returns:
Current execution metadata
- Return type:
- 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 stdinoptions (
Unpack[LongRequestOptions]) – Request configuration forwarded to the generated client
- Raises:
RunloopError – If the API reports unsuccessful delivery
- Return type:
- 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:
- async kill(**options)[source]¶
Request termination of the running execution.
- Parameters:
options (
Unpack[LongRequestOptions]) – Optional long-running request configuration- Return type:
Execution management for async commands.
- class runloop_api_client.sdk.execution.Execution(client, devbox_id, execution, streaming_group=None)[source]¶
Manages an asynchronous command execution on a devbox.
Provides methods to poll execution state, wait for completion, and terminate the running process. Created by
devbox.cmd.exec_async().Example
>>> execution = devbox.cmd.exec_async("python train.py") >>> state = execution.get_state() >>> if state.status == "running": ... execution.kill() >>> result = execution.result() # Wait for completion >>> print(result.stdout())
- property execution_id: str¶
Return the execution identifier.
- Returns:
Unique execution ID
- Return type:
- property devbox_id: str¶
Return the devbox identifier.
- Returns:
Devbox ID where the command is running
- Return type:
- result(**options)[source]¶
Wait for completion and return an
ExecutionResult.- Parameters:
options (
Unpack[LongRequestOptions]) – Optional long-running request configuration- Returns:
Wrapper with exit status and output helpers
- Return type:
- get_state(**options)[source]¶
Fetch the latest execution state.
- Parameters:
options (
Unpack[BaseRequestOptions]) – Optional request configuration- Returns:
Current execution metadata
- Return type:
- 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 stdinoptions (
Unpack[LongRequestOptions]) – Request configuration forwarded to the generated client
- Raises:
RunloopError – If the API reports unsuccessful delivery
- Return type:
- 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:
- kill(**options)[source]¶
Request termination of the running execution.
- Parameters:
options (
Unpack[LongRequestOptions]) – Optional long-running request configuration- Return type: