AerJob#

class AerJob(backend, job_id, fn, circuits=None, parameter_binds=None, run_options=None, executor=None)[source]#

Bases: JobV1

AerJob class for Aer Simulators.

Initializes the asynchronous job.

Parameters:
  • backend (AerBackend) – the backend used to run the job.

  • job_id (str) – a unique id in the context of the backend used to run the job.

  • fn (function) – a callable function to execute qobj on backend. This should usually be a bound AerBackend._run() method, with the signature (qobj: QasmQobj, job_id: str) -> Result.

  • circuits (list of QuantumCircuit) – circuits to execute.

  • parameter_binds (list) – parameters for circuits.

  • run_options (dict) – run_options to execute.

  • executor (ThreadPoolExecutor) – The executor to be used to submit the job.

Raises:

JobError – if no qobj and no circuits.

Attributes

version = 1#

Methods

backend()[source]#

Return the instance of the backend used for this job.

cancel()[source]#

Attempt to cancel the job.

cancelled() bool[source]#

Return whether the job has been cancelled.

circuits()[source]#

Return the list of QuantumCircuit submitted for this job.

Returns:

the list of QuantumCircuit submitted for this job.

Return type:

list of QuantumCircuit

done() bool[source]#

Return whether the job has successfully run.

executor()[source]#

Return the executor for this job

in_final_state() bool[source]#

Return whether the job is in a final job state such as DONE or ERROR.

job_id() str[source]#

Return a unique id identifying the job.

result(timeout=None)[source]#

Get job result. The behavior is the same as the underlying concurrent Future objects,

https://docs.python.org/3/library/concurrent.futures.html#future-objects

Parameters:

timeout (float) – number of seconds to wait for results.

Returns:

Result object

Return type:

qiskit.Result

Raises:
  • concurrent.futures.TimeoutError – if timeout occurred.

  • concurrent.futures.CancelledError – if job cancelled before completed.

running() bool[source]#

Return whether the job is actively running.

status()[source]#

Gets the status of the job by querying the Python’s future

Returns:

The current JobStatus

Return type:

JobStatus

Raises:
  • JobError – If the future is in unexpected state

  • concurrent.futures.TimeoutError – if timeout occurred.

submit()[source]#

Submit the job to the backend for execution.

Raises:
  • QobjValidationError – if the JSON serialization of the Qobj passed

  • during construction does not validate against the Qobj schema.

  • JobError – if trying to re-submit the job.

wait_for_final_state(timeout: float | None = None, wait: float = 5, callback: Callable | None = None) None[source]#

Poll the job status until it progresses to a final state such as DONE or ERROR.

Parameters:
  • timeout – Seconds to wait for the job. If None, wait indefinitely.

  • wait – Seconds between queries.

  • callback

    Callback function invoked after each query. The following positional arguments are provided to the callback function:

    • job_id: Job ID

    • job_status: Status of the job from the last query

    • job: This BaseJob instance

    Note: different subclass might provide different arguments to the callback function.

Raises:

JobTimeoutError – If the job does not reach a final state before the specified timeout.