qiskit.providers.basicaer.BasicAerJob
class BasicAerJob(backend, job_id, fn, qobj)
BasicAerJob class.
_executor
executor to handle asynchronous jobs
Type
futures.Executor
Initializes the asynchronous job.
Parameters
- backend – the backend used to run the job.
- job_id – a unique id in the context of the backend used to run the job.
__init__
__init__(backend, job_id, fn, qobj)
Initializes the asynchronous job.
Parameters
- backend – the backend used to run the job.
- job_id – a unique id in the context of the backend used to run the job.
Methods
__init__ (backend, job_id, fn, qobj) | Initializes the asynchronous job. |
backend () | Return the instance of the backend used for this job. |
cancel () | Attempt to cancel the job. |
cancelled () | Return whether the job has been cancelled. |
done () | Return whether the job has successfully run. |
in_final_state () | Return whether the job is in a final job state. |
job_id () | Return a unique id identifying the job. |
qobj () | Return the Qobj submitted for this job. |
result ([timeout]) | Get job result. |
running () | Return whether the job is actively running. |
status () | Gets the status of the job by querying the Python’s future |
submit () | Submit the job to the backend for execution. |
wait_for_final_state ([timeout, wait, callback]) | Poll the job status until it progresses to a final state such as DONE or ERROR . |
backend
backend()
Return the instance of the backend used for this job.
cancel
cancel()
Attempt to cancel the job.
cancelled
cancelled()
Return whether the job has been cancelled.
Return type
bool
done
done()
Return whether the job has successfully run.
Return type
bool
in_final_state
in_final_state()
Return whether the job is in a final job state.
Return type
bool
job_id
job_id()
Return a unique id identifying the job.
Return type
str
qobj
result
result(timeout=None)
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
running()
Return whether the job is actively running.
Return type
bool
status
status()
Gets the status of the job by querying the Python’s future
Returns
The current JobStatus
Return type
Raises
- JobError – If the future is in unexpected state
- concurrent.futures.TimeoutError – if timeout occurred.
submit
submit()
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
wait_for_final_state(timeout=None, wait=5, callback=None)
Poll the job status until it progresses to a final state such as DONE
or ERROR
.
Parameters
-
timeout (
Optional
[float
]) – Seconds to wait for the job. IfNone
, wait indefinitely. -
wait (
float
) – Seconds between queries. -
callback (
Optional
[Callable
]) –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.
Return type
None