Skip to content

Markdown

Retries

A 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 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.

RetryPolicy

How to retry rate limits, connection failures, and reads that failed on the way.

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 rather than obey a longer Retry-After.
RetryPolicy(
    *,
    max_retries: int = 4,
    base_delay: float = 1.0,
    max_delay: float = 30.0,
    max_retry_after: float = 60.0,
)

Example

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())
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

3

Get the backoff delay

Exponential backoff with jitter, so parallel clients don't retry in lockstep.

Parameters

  • attempt int, required
    Which retry this is, starting from 0.

Returns float

The seconds to wait.

backoff(attempt: int) -> float

Get the wait after a 429

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.

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.

rate_limit_delay(
    attempt: int, retry_after: float | None
) -> float | None