Job
class qiskit_serverless.Job(job_id, job_service, raw_data=None)
Handle for a managed workflow job. Returned by run(), ManagedWorkflowClient.job(), and ManagedWorkflowClient.jobs().
job = workflow.run(**inputs)
job.wait_for_final_state(timeout=600, verbose=True)
result = job.result()Status
status
status()
Returns the job status: QUEUED, INITIALIZING, RUNNING, CANCELING, DONE, ERROR, or CANCELED. While a workflow reports a stage with update_status(), RUNNING becomes a value such as RUNNING: WAITING_FOR_QPU. See Stage constants.
print(job.status())Output:
QUEUEDReturn type
str
Stage constants
Pass these to update_status() from inside a workflow to report its stage.
Constant | status() returns |
|---|---|
Job.MAPPING | RUNNING: MAPPING |
Job.OPTIMIZING_HARDWARE | RUNNING: OPTIMIZING_FOR_HARDWARE |
Job.WAITING_QPU | RUNNING: WAITING_FOR_QPU |
Job.EXECUTING_QPU | RUNNING: EXECUTING_QPU |
Job.POST_PROCESSING | RUNNING: POST_PROCESSING |
wait_for_final_state
wait_for_final_state(timeout=None, poll_interval=None, verbose=False)
Waits until the job is DONE, ERROR, or CANCELED and returns that status. By default it checks after 1, 2, 4, 8, 16, and 32 seconds, then every 60 seconds. Short network errors are retried.
status = job.wait_for_final_state(timeout=600, verbose=True)
print(status)Output:
Waiting for job e6b1ffa1-cd26-437d-bd53-b265dd4ba952
0:00:00 QUEUED
0:00:17 INITIALIZING
0:03:00 RUNNING
0:03:14 DONE
DONEParameters
- timeout (float | None) – Seconds to wait.
Nonewaits until the job ends. - poll_interval (float | None) – Fixed seconds between checks, at least 1. Replaces the default backoff.
- verbose (bool) – Print one line per status change.
Return type
str
Raises
TimeoutError– If the job doesn't finish withintimeout. The job keeps running.QiskitServerlessException– On other errors, or if retried errors continue for 5 minutes.
in_terminal_state
in_terminal_state()
Returns whether the job has finished.
print(job.in_terminal_state())Output:
TrueReturn type
bool
events
events(**kwargs)
Returns the job's events.
for event in job.events():
print(event.created, event.event_type, event.data.get("status"))Output:
2026-11-02T14:43:07.134377Z STATUS_CHANGE QUEUED
2026-11-02T14:43:24.474199Z STATUS_CHANGE PENDING
2026-11-02T14:46:07.309519Z STATUS_CHANGE RUNNING
2026-11-02T14:46:21.115038Z STATUS_CHANGE SUCCEEDEDReturn type
list[JobEvent]
Results and logs
result
result(wait=True, cadence=30, verbose=False, maxwait=0)
Returns the job's result: the value the job passed to save_result().
job.result()Output:
{'theta': 0.5, 'expectation_value': 0.8775825618903728}Parameters
- wait (bool) – Wait for the job to finish.
- cadence (int) – Seconds between status checks while waiting.
- verbose (bool) – Log a line at each check.
- maxwait (int) – Maximum number of checks.
0waits until the job finishes.
Raises
QiskitServerlessException – If the job ended in ERROR.
logs
logs()
Returns the job's logs. See Write logs and handle errors.
print(job.logs())Output:
Computing the expectation value for theta=0.5Return type
str
filtered_logs
filtered_logs(include=None, exclude=None)
Returns the job's logs, filtered by line.
print(job.filtered_logs(include="theta"))Output:
Computing the expectation value for theta=0.5Parameters
- include (str | None) – Regular expression. Keep only matching lines.
- exclude (str | None) – Regular expression. Drop matching lines.
Return type
str
error_message
error_message()
Returns the error message if the job failed.
print(job.error_message())Output:
| Message: The circuit has more qubits than the backend.
| Code: 4500
| Exception: InputError
| Details:
| - circuit_qubits: 10
| - backend_qubits: 5Return type
str
Control
cancel
cancel(service=None)
Cancels the job. Replaces the deprecated stop().
job.cancel()
print(job.wait_for_final_state())Output:
CANCELEDParameters
- service (QiskitRuntimeService | None) – Quantum Compute service to cancel the job's Quantum Compute jobs with.
IBM Quantum Compute jobs
The Quantum Compute jobs and sessions that this job submitted.
runtime_jobs
runtime_jobs(runtime_session=None)
Returns the IDs of the Quantum Compute jobs this job created, optionally filtered by session.
print(job.runtime_jobs())
sessions = job.runtime_sessions()
print(job.runtime_jobs(runtime_session=sessions[0]))Output:
['dbl6lst8ft8s738secf0']
['dbl6lst8ft8s738secf0']Return type
list[str]
runtime_sessions
runtime_sessions()
Returns the IDs of the Quantum Compute sessions this job created.
print(job.runtime_sessions())Output:
['cw2q70c79ws0008z6g4g']Return type
list[str]