# Execution and Request timeouts

### Job Execution-Duration Timeout

Programs run on a QPU always have a *job execution-duration timeout*; this is the maximum time a program can spend executing (not including time spent queued for execution). When the timeout expires, if the program is still running, it is halted; in some cases, it may be retried automatically.

The job timeout is based on the expected execution duration. When possible, this is calculated automatically as part of program translation. However, users may [request a longer timeout](https://docs.api.qcs.rigetti.com/protobuf/index.html#services.controller.ExecutionOptions) as part of the job-execution request. There is a maximum job timeout on each QPU, and jobs that request a longer timeout than the maximum will be rejected. If a program uses dynamic control flow, it is given a default timeout rather than a calculated estimate (see: [Halting Problem](https://en.wikipedia.org/wiki/Halting_problem)).

The job timeout is applied to each program execution attempt individually. This means that for parametric or batch execution, each job or execution configuration will have the full timeout duration during which to execute.

{% hint style="info" %}
PyQuil's `execution_timeout` argument of [the `get_qc` function](https://pyquil-docs.rigetti.com/en/stable/apidocs/pyquil.api.html#pyquil.api.get_qc) does *not* actually set the job execution-duration timeout; rather, it determines the request timeout for all requests to the job-execution service. This includes job submission, getting the job status, and retrieving job results.
{% endhint %}

### Request Timeout

Separately, [QCS clients automatically enforce](#user-content-fn-1)[^1] *request timeouts*, cancelling any requests that last too long. In particular, retrieving execution results may time out before the program has finished or even started executing, for instance if the program is queued for execution for longer than expected. The request timeout is not part of the QCS API; the execution service is completely unaware of the client's request timeout. *Execution* and *request* timeouts are therefore completely separate and unrelated.

If a request to retrieve execution results for a specific program times out, the corresponding program is not cancelled; it may still complete successfully. A second request for results may be successful.

Request timeouts are configurable, but different gRPC clients support different means of configuration. Consult the API documentation for your specific client or SDK library.

{% hint style="info" %}
There is also a [timeout troubleshooting section](https://pyquil-docs.rigetti.com/en/stable/troubleshooting.html#timeout-in-execution) in the pyQuil documentation.
{% endhint %}

[^1]: remove annotation
