Skip to main content
IBM Quantum Platform

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:

QUEUED

Return type

str

Stage constants

Pass these to update_status() from inside a workflow to report its stage.

Constant
status() returns
Job.MAPPINGRUNNING: MAPPING
Job.OPTIMIZING_HARDWARERUNNING: OPTIMIZING_FOR_HARDWARE
Job.WAITING_QPURUNNING: WAITING_FOR_QPU
Job.EXECUTING_QPURUNNING: EXECUTING_QPU
Job.POST_PROCESSINGRUNNING: 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
DONE

Parameters

  • timeout (float | None) – Seconds to wait. None waits 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 within timeout. 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:

True

Return 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 SUCCEEDED

Return 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. 0 waits 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.5

Return 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.5

Parameters

  • 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: 5

Return type

str


Control

cancel

cancel(service=None)

Cancels the job. Replaces the deprecated stop().

job.cancel()
print(job.wait_for_final_state())

Output:

CANCELED

Parameters

  • 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]

Was this page helpful?
Report a bug, typo, or request content on GitHub.