---
sidebar:
  label: roboto.http.retry
  order: 8
title: roboto.http.retry
---
## Module Contents

### RetryWaitFn

```python
roboto.http.retry.RetryWaitFn
```

`from roboto.http.retry import RetryWaitFn`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/retry.py#L12-L12)

Function that chooses how long to wait before the next attempt of a request, and returns that wait in milliseconds.

It takes the `tenacity.RetryCallState` of the request and an exception, which [`HttpClient`](/docs/reference/python-sdk/roboto/http/http_client#roboto.http.http_client.HttpClient) always passes as `None`.

### default_retry_wait_ms()

```python
def roboto.http.retry.default_retry_wait_ms(
    retry_state: tenacity.RetryCallState,
    _exc: Optional[BaseException],
) -> float
```

`from roboto.http.retry import default_retry_wait_ms`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/http/retry.py#L20-L39)

Return a random wait before the next attempt of a request, in milliseconds.

[`HttpRequest`](/docs/reference/python-sdk/roboto/http/request#roboto.http.request.HttpRequest) uses this when it is built without a `retry_wait`. The wait is up to 1 second after the first attempt, and that limit doubles after each attempt, up to 30 seconds. Choosing the wait at random keeps clients whose requests failed at the same moment from retrying at the same moment. This is the "full jitter" backoff described at [https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/).

**Parameters**

- **retry_state** (`tenacity.RetryCallState`): Retry state of the request. Its `attempt_number` counts the attempts made so far, from 1.
- **`_exc`** (`Optional[BaseException]`)

**Returns**

- `float`: Milliseconds to wait, from 0 to 30,000.
