Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/prime-sandboxes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ print(f"Job started: {job.job_id}")
# same bounded stdout/stderr tails as get_background_job().
statuses = sandbox_client.get_background_jobs([job])

# For latency-sensitive polling, status-only methods never download output.
# Fetch the hydrated result with get_background_job() after completion.
snapshots = sandbox_client.get_background_job_statuses([job])

# Poll for completion
import time
while True:
Expand All @@ -256,7 +260,16 @@ sandbox_client.download_file(sandbox.id, "/app/model.pt", "./model.pt")
```

`get_background_jobs` is VM-only. Container sandboxes retain the existing
`get_background_job` polling behavior.
`get_background_job` polling behavior. Once an exit code is observed, completion
remains authoritative even if output retrieval exhausts its bounded retry
deadline: the unavailable stream is `None` and its `stdout_error` or
`stderr_error` field describes the retrieval failure.

Output downloads are deduplicated, cached within a bounded client-local LRU,
and scheduled separately from completion polling. Advanced callers can tune the
client-wide limits with `background_job_output_concurrency`,
`background_job_output_queue_size`, and `background_job_output_cache_bytes`;
the defaults are 20 active jobs, 200 queued jobs, and 64 MiB of cached streams.

#### Async version

Expand Down
2 changes: 2 additions & 0 deletions packages/prime-sandboxes/src/prime_sandboxes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
AdvancedConfigs,
BackgroundJob,
BackgroundJobStatus,
BackgroundJobStatusSnapshot,
BatchSandboxStatusResponse,
BuildImageRequest,
BuildImageResponse,
Expand Down Expand Up @@ -117,6 +118,7 @@
"AdvancedConfigs",
"BackgroundJob",
"BackgroundJobStatus",
"BackgroundJobStatusSnapshot",
"BatchSandboxStatusResponse",
"SandboxStatusSnapshot",
"SandboxStatusLookupError",
Expand Down
2 changes: 2 additions & 0 deletions packages/prime-sandboxes/src/prime_sandboxes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,8 @@ class BackgroundJobStatus(BaseModel):
exit_code: Optional[int] = None
stdout: Optional[str] = None
stderr: Optional[str] = None
stdout_error: Optional[str] = None
stderr_error: Optional[str] = None
stdout_truncated: bool = False
stderr_truncated: bool = False

Expand Down
Loading
Loading