Jobs
Reference for sandbox jobs and image jobs: follow one to its end, read its log, write to its stdin, signal or remove it.
A job is a sandbox’s process, from exec, or an image’s build, pull or push.
A call that starts one returns a StartedJob: awaited, it is the job; iterated, it yields the job’s log; complete follows it to its end.
See Running commands.
| Member | Does |
|---|---|
StartedJob |
A job as it starts. |
SandboxJob |
A process started in a sandbox. |
complete |
Follows the job to its end, printing its output if print, and returns its exit code: 128 + signal for one a signal ended. |
log |
Its output, from its start or after entry after, until its end entry: a LogEntry at a time, each numbered by id to resume from. |
signal |
Sends a signal, such as "SIGTERM", to its process and every process it started. |
write_stdin |
Writes to the stdin of a job started with stdin, and closes it if eof. |
get |
The job as the server has it now. |
remove |
Kills its process if it runs, or cancels an image job, and forgets the job. |
ImageJob |
A build, pull or push, from awaiting build_image, pull_image or push_image, or from get_image_job(id). |
list_image_job |
The server’s image jobs, or the one id. |
StartedJob
A job as it starts. In Python, the job starts the first time the value is awaited or iterated, and only then; in Node.js and Rust, it starts at the call. It starts once, however the value is used: awaited, iterated, completed, or each. Each loop reads the log from its start; leaving one leaves the job running, which the job’s remove cancels.
class StartedJob(Generic[J, E]): def __await__(self) -> Generator[Any, None, J] def __aiter__(self) -> AsyncIterator[LogEntry[E]] async def complete(print: bool = False) -> Tclass StartedJob<J, E> extends Promise<J> implements AsyncIterable<E> { complete(options?: { print?: boolean }): Promise<T>}impl<J, E> StartedJob<J, E> { // awaited: Result<J, Error> pub fn wait(self) -> Result<J, Error> pub fn log(self) -> JobLog<J, E> pub fn complete(self, print: bool) -> JobEnd<J>}SandboxJob
A process started in a sandbox. It has its id, its sandbox_id, its kind, pid, cmd, whether it is running, and once it has ended, its exit code and, if it did not end by itself, the reason: timeout, cancelled, sandbox_deleted, vm_exited, oom, or restarted, for one that ran when its server restarted, keeping its sandbox. A reason this version doesn’t know is kept as the string the server sent.
Code that holds only ids gets the job back with get_sandbox(id), then its job(id). In Rust, SandboxJob has id(), sandbox_id() and info().
class SandboxJob: sandbox_id: str id: str kind: SandboxJobKind pid: int cmd: list[str] running: bool code: int | None reason: SandboxJobEndReason | Noneclass SandboxJob { readonly sandboxId: string id: string kind: 'exec' pid: number cmd: string[] running: boolean code?: number reason?: SandboxJobEndReason}impl SandboxJob { pub fn id(&self) -> &str pub fn sandbox_id(&self) -> &str pub fn info(&self) -> &SandboxJobInfo}complete
Follows the job to its end, printing its output if print, and returns its exit code: 128 + signal for one a signal ended. An image job returns the digest it made, and raises the error it failed with.
async def complete(print: bool = False) -> int # ImageJob: -> strcomplete(options?: { print?: boolean }): Promise<number> // ImageJob: Promise<string>pub fn complete(&self, print: bool) -> JobEnd<SandboxJob> // awaited: Result<i32, Error>log
Its output, from its start or after entry after, until its end entry: a LogEntry at a time, each numbered by id to resume from. A sandbox job’s entries are stdout, stderr, truncated and end; an image job’s are log, truncated and end, or the error it failed with in place of its end. An entry of a kind this version doesn’t know is skipped in Python and Node.js, and is SandboxJobEntry::Other or ImageJobEntry::Other in Rust, which complete skips.
async def log(after: int | None = None) -> AsyncIterator[LogEntry[SandboxJobEntry]]log(after?: number): AsyncGenerator<SandboxJobEntry>pub fn log(&self, after: Option<u64>) -> Events<LogEntry<SandboxJobEntry>>signal
Sends a signal, such as "SIGTERM", to its process and every process it started. Sandbox jobs only.
async def signal(signal: str) -> Nonesignal(signal: string): Promise<void>pub fn signal(&self, signal: impl AsRef<str>) -> Call<()>write_stdin
Writes to the stdin of a job started with stdin, and closes it if eof. Await each write before the next.
A write its process closed its stdin under part-way raises 409, ended, its written how many bytes went in. One the server has no room for yet is turned away as 503 capacity, nothing of it taken, and, if its request is at most 1 MiB, sent again as Errors says.
async def write_stdin(data: str | None = None, eof: bool = False) -> NonewriteStdin(data?: string, eof?: boolean): Promise<void>pub fn write_stdin(&self, data: Option<impl Into<String>>, eof: bool) -> Call<()>get
The job as the server has it now.
async def get() -> SandboxJobget(): Promise<SandboxJob>pub fn get(&self) -> Call<SandboxJob>remove
Kills its process if it runs, or cancels an image job, and forgets the job.
async def remove() -> Noneremove(): Promise<void>pub fn remove(&self) -> Call<()>ImageJob
A build, pull or push, from awaiting build_image, pull_image or push_image, or from get_image_job(id). It has its id, its kind, the reference it points or pushes, whether it is running, and once it has ended, the digest it made or the error it failed with. It takes get, complete, log and remove as above. In Rust, ImageJob has id() and info().
class ImageJob: id: str kind: ImageJobKind # pull | push | build reference: str running: bool digest: str | None error: str | Noneclass ImageJob { id: string kind: 'pull' | 'push' | 'build' reference: string running: boolean digest?: string error?: string}impl ImageJob { pub fn id(&self) -> &str pub fn info(&self) -> &ImageJobInfo}list_image_job
The server’s image jobs, or the one id.
async def list_image_job() -> list[ImageJob]async def get_image_job(id: str) -> ImageJoblistImageJob(): Promise<ImageJob[]>getImageJob(id: string): Promise<ImageJob>pub fn list_image_job(&self) -> Call<Vec<ImageJob>>pub fn get_image_job(&self, id: impl AsRef<str>) -> Call<ImageJob>Errors
A call that fails raises a VirtxError in Python, throws one in Node.js, and returns one in Rust. Branch on its status and code, not its message. These are the errors the calls on this page return most often.
| Error | From | Cause |
|---|---|---|
404, not_found |
get, log, job(id) |
The job was removed, or more than 100 jobs have ended since it did. Read its output sooner, or have the command write it to a volume. |
the job was removed before it ended |
complete |
The job was removed while complete waited for it. |
409, ended |
signal |
The job has already ended. |
409, ended |
write_stdin |
The job was started without stdin, its stdin is closed, or it has ended. A write cut part-way also has written, the bytes that went in. |
503, capacity |
write_stdin |
The process hasn’t read earlier writes yet. Nothing was written; the client sends it again by itself. |
source job |
complete on an ImageJob |
The build, pull or push failed, such as a build step that exited nonzero. The log says why. |
Any call can also fail with 401, unauthorized or 403, forbidden (see Client), or with source transport when the connection drops. The client retries 503, capacity and a 429, quota for the request rate by itself for up to 30 seconds: see Retries.