To cancel a job in Azure Quantum, you can use the cancel()
method of the job object. However, this method only works for jobs that are not yet in a final state, such as succeeded
, failed
, or cancelled
. If you have a lot of jobs stuck in the waiting
state, you can cancel them programmatically by iterating over the list of jobs and cancelling each one that is in the waiting
state. Here's an example Python code snippet that cancels all jobs in the waiting
state:
for job in workspace.list_jobs():
if job.status == 'waiting':
job.cancel()
Note that cancelling a job after it has started running may still result in partial or full billing for that job. For more information, see the billing documentation for your selected provider.
References: