Job
Background job execution and status polling.
Job (Sync)
Represents a background job execution submitted via flow.job().
Methods
status() -> JobStatus
Poll the current job status.
Returns: JobStatus object with state and results
Raises:
- Network/API errors
Example:
wait(*, timeout_ms=None) -> ExecuteResult
Wait for the job to complete and return the result.
Parameters:
timeout_ms(int, optional): Maximum time to wait in milliseconds. Default: None (wait indefinitely)
Returns: ExecuteResult when complete
Raises:
TimeoutErroriftimeout_msis exceeded- Network/API errors
Example:
cancel() -> None
Cancel a running job. Has no effect if the job is already complete.
Example:
Properties
id (str)
Unique job identifier.
Example:
AsyncJob
Async equivalent of Job. All methods are awaitable.
Methods
async status() -> JobStatus
Poll the current job status (awaitable).
Example:
async wait(*, timeout_ms=None) -> ExecuteResult
Wait for the job to complete (awaitable).
Example:
async cancel() -> None
Cancel a running job (awaitable).
Example:
JobStatus (Type)
Job status information.
Attributes:
id(str): Job IDstate(str): One of"pending","running","completed","failed","cancelled"result(ExecuteResult, optional): Final result if completederror(str, optional): Error message if failedcreated_at(str): ISO 8601 timestamp of job creationstarted_at(str, optional): ISO 8601 timestamp when job startedcompleted_at(str, optional): ISO 8601 timestamp when job completedprogress(dict, optional): Progress metadata (implementation-specific)
Example:
JobAccepted (Type)
Response when a job is successfully submitted (via flow.job()).
Attributes:
id(str): Job ID (same asJob.id)state(str): Always"pending"
Example:
Job Lifecycle
- Submit via
flow.job(...)→ returnsJob - Poll via
job.status()→ returnsJobStatuswith current state - Wait via
job.wait()→ blocks until complete - Cancel (optional) via
job.cancel() - Retrieve result from
JobStatus.resultorjob.wait()return value
Example: