Documentation Index
Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
Use this file to discover all available pages before exploring further.
Source: src/cwsandbox/_types.py:488
class Process(future: concurrent.futures.Future[ProcessResult], command: list[str], stdout: StreamReader[str], stderr: StreamReader[str], stdin: StreamWriter | None = None, stats_callback: Callable[[ProcessResult | None, BaseException | None], None] | None = None)
Handle for a running process with streaming stdout/stderr.
Process inherits from OperationRef[ProcessResult] and adds streaming
capabilities and process-specific methods. It wraps an async operation
that executes a command in a sandbox.
The process’s output streams (stdout, stderr) can be iterated either
synchronously or asynchronously. The result() method blocks until
completion and returns the full ProcessResult.
Properties
returncode
@property
def returncode(self) -> int | None
The process exit code, or None if not yet complete.
command
@property
def command(self) -> list[str]
The command that was executed.
Methods
poll
Check if the process has completed without blocking.
Returns
int | None: The exit code if the process has completed, None otherwise.
wait
wait(timeout: float | None = None) -> int
Block until the process completes.
Parameters
timeout (float | None): Maximum seconds to wait. None means wait forever.
Returns
int: The process exit code.
Raises
concurrent.futures.TimeoutError: If timeout expires.
concurrent.futures.CancelledError: If the operation was cancelled.
Exception: Any exception from the execution.
result
result(timeout: float | None = None) -> ProcessResult
Block until complete and return the full ProcessResult.
Parameters
timeout (float | None): Maximum seconds to wait. None means wait forever.
Returns
ProcessResult: The ProcessResult containing stdout, stderr, and exit code.
Raises
concurrent.futures.TimeoutError: If timeout expires.
concurrent.futures.CancelledError: If the operation was cancelled.
Exception: Any exception from the execution.
cancel
Attempt to cancel the process.
Returns
bool: True if successfully cancelled, False otherwise.