# pyquickbase API reference: Retries This describes version 1.0.0rc13. Other pages: [Quickbase](https://matthew-williams-solutions.github.io/pyquickbase/reference/quickbase.txt), [App](https://matthew-williams-solutions.github.io/pyquickbase/reference/app.txt), [Table](https://matthew-williams-solutions.github.io/pyquickbase/reference/table.txt), [Report](https://matthew-williams-solutions.github.io/pyquickbase/reference/report.txt), [Operation](https://matthew-williams-solutions.github.io/pyquickbase/reference/operation.txt), [SchemaOperation](https://matthew-williams-solutions.github.io/pyquickbase/reference/schema-operation.txt), [Queries](https://matthew-williams-solutions.github.io/pyquickbase/reference/queries.txt), [Records and results](https://matthew-williams-solutions.github.io/pyquickbase/reference/records.txt), [Metadata](https://matthew-williams-solutions.github.io/pyquickbase/reference/metadata.txt), [Schema changes](https://matthew-williams-solutions.github.io/pyquickbase/reference/schema-changes.txt), [Policies](https://matthew-williams-solutions.github.io/pyquickbase/reference/policies.txt), [Rules](https://matthew-williams-solutions.github.io/pyquickbase/reference/rules.txt), [Tools for models](https://matthew-williams-solutions.github.io/pyquickbase/reference/tools.txt), [Errors](https://matthew-williams-solutions.github.io/pyquickbase/reference/errors.txt). A [`RetryPolicy`](https://matthew-williams-solutions.github.io/pyquickbase/reference/retries/#RetryPolicy) says how a client retries a request that hit a rate limit or a connection failure, and how long it waits. Pass one to [`Quickbase`](https://matthew-williams-solutions.github.io/pyquickbase/reference/quickbase/) as `retry`. Each example makes its own client from the environment, with `bqtasks123` standing for the ID of the `Job Tasks` table. A live test runs every example with both clients and checks its output. ## Retrying requests For the full picture, see [Configuring clients](https://matthew-williams-solutions.github.io/pyquickbase/guides/clients/). ### `RetryPolicy` How to retry rate limits, connection failures, and reads that failed on the way. ```python RetryPolicy( *, max_retries: int = 4, base_delay: float = 1.0, max_delay: float = 30.0, max_retry_after: float = 60.0, ) ``` **Parameters** - **`max_retries`** `int`, default `4` Retries after the first attempt. Use 0 to disable retrying. - **`base_delay`** `float`, default `1.0` Starting backoff in seconds, when Quickbase doesn't specify a wait or says to wait 0 seconds. - **`max_delay`** `float`, default `30.0` Longest backoff in seconds. - **`max_retry_after`** `float`, default `60.0` Raise [`RateLimitError`](https://matthew-williams-solutions.github.io/pyquickbase/reference/errors/#RateLimitError) rather than obey a longer `Retry-After`. #### `RetryPolicy.backoff()` Exponential backoff with jitter, so parallel clients don't retry in lockstep. ```python backoff(attempt: int) -> float ``` **Parameters** - **`attempt`** `int`, required Which retry this is, starting from 0. **Returns** `float` The seconds to wait. #### `RetryPolicy.rate_limit_delay()` Seconds to wait after a 429, or None if the wait is too long to be worth it. Quickbase can send a wait of 0 while it's still limiting, so an immediate retry could use up the retries, and that's treated like no wait at all. ```python rate_limit_delay( attempt: int, retry_after: float | None ) -> float | None ``` **Parameters** - **`attempt`** `int`, required Which retry this is, starting from 0. - **`retry_after`** `float | None`, required The wait Quickbase asked for, in seconds, if it did. **Returns** `float | None` The seconds to wait, or None to stop retrying and raise [`RateLimitError`](https://matthew-williams-solutions.github.io/pyquickbase/reference/errors/#RateLimitError). Sync example: ```python from pyquickbase import Quickbase, RetryPolicy patient = RetryPolicy(max_retries=6, max_delay=60) with Quickbase.from_env(retry=patient) as qb: tasks = qb.app("bq1234567").table("bqtasks123") print(tasks.count()) ``` Async example: ```python from pyquickbase import AsyncQuickbase, RetryPolicy patient = RetryPolicy(max_retries=6, max_delay=60) async with AsyncQuickbase.from_env(retry=patient) as qb: tasks = qb.app("bq1234567").table("bqtasks123") print(await tasks.count()) ``` Output: ```text 3 ```