qc.run calls can fail due to a connection timeout when jobs are stuck in the queue for a while.
As is there's no retries to fetch results, so the execution is abandoned because the results can't be re-fetched.
You can get around this today by splitting the qc.run call into separate qc.qam.{execute,get_result} calls, but it probably makes sense to build some ergonomics in to pyquil itself to automatically retry.
Note that qcs-sdk should probably also use get_controller_job_status when awaiting a long-queued jobs, perhaps to periodically print "still queued..." so that the user knows what's going on.
job_id = qc.qam.execute(exe)
while True:
try:
# this can be retried on timeout - but not on 404
result = qc.qam.get_result(job_id)
break
except Exception as e:
if "tcp connect error" in str(e):
print(f"Timeout retrieving job {job_id} result, retrying...")
continue
raise e
# use results typically ---
print(result.get_register_map()["ro"])
qc.runcalls can fail due to a connection timeout when jobs are stuck in the queue for a while.As is there's no retries to fetch results, so the execution is abandoned because the results can't be re-fetched.
You can get around this today by splitting the
qc.runcall into separateqc.qam.{execute,get_result}calls, but it probably makes sense to build some ergonomics in to pyquil itself to automatically retry.Note that
qcs-sdkshould probably also useget_controller_job_statuswhen awaiting a long-queued jobs, perhaps to periodically print "still queued..." so that the user knows what's going on.