# ovok_sdk.http.retry

Canonical page: https://docs.ovok.com/python-sdk/reference/http/retry

When and how long to wait before retrying a request.

## RetryPolicy [#retrypolicy]

```python
RetryPolicy(max_retries: int, sleep: Sleep = time.sleep)
```

Retries safe requests on network failures and 429, 502, 503 and 504, with backoff.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `max_retries` | `int` |  | Retries allowed after the first attempt. |
| `sleep` | `Sleep` | `time.sleep` | Waits the given number of seconds. |

### allows() [#allows]

```python
allows(request: HttpRequest, attempt: int) -> bool
```

Whether `request` may be retried after failed attempt number `attempt` (0-based).

### is_retryable_status() [#is_retryable_status]

```python
is_retryable_status(status: int) -> bool
```

Whether a response with `status` is worth retrying.

### pause() [#pause]

```python
pause(attempt: int, retry_after_ms: int | None) -> None
```

Wait before the next attempt: `retry_after_ms` if given, else exponential backoff, at most 5 s.

## retry_after_ms() [#retry_after_ms]

```python
retry_after_ms(header: str | None) -> int | None
```

Reads Retry-After as seconds or an HTTP date; a past moment means now.

**Returns**

- `int | None`: The delay in milliseconds, or None when the header is absent or unreadable.
