> ## Documentation Index
> Fetch the complete documentation index at: https://alibi.itsdote.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# alibi_sdk.backoff

> Retry / backoff — generated from python/alibi_sdk source.

Exponential backoff with full jitter for CP connectivity + pool waits.

*Source:* [`python/alibi_sdk/alibi_sdk/backoff.py`](https://github.com/valid22/alibi-ai/blob/main/python/alibi_sdk/alibi_sdk/backoff.py)

### `env_int`

```python theme={null}
def env_int(name: str, default: int) -> int
```

**Parameters**

| Name | Type |
| - | - |
| `name` | `str` |
| `default` | `int` |

**Returns**

`int`

### `env_float`

```python theme={null}
def env_float(name: str, default: float) -> float
```

**Parameters**

| Name | Type |
| - | - |
| `name` | `str` |
| `default` | `float` |

**Returns**

`float`

### `compute_backoff_ms`

```python theme={null}
def compute_backoff_ms(attempt: int, base_ms: Optional[float] = None, max_ms: Optional[float] = None) -> float
```

Full-jitter exponential backoff.

attempt=0 → \[0, base]; attempt=1 → \[0, 2\*base]; capped at max\_ms.

**Parameters**

| Name | Type |
| - | - |
| `attempt` | `int` |
| `base_ms` | `Optional[float]` |
| `max_ms` | `Optional[float]` |

**Returns**

`float`

### `retry_with_backoff`

```python theme={null}
async def retry_with_backoff(fn: Callable[[], Awaitable[T]], max_retries: Optional[int] = None, base_ms: Optional[float] = None, max_ms: Optional[float] = None, retry_on: Optional[Callable[[BaseException], bool]] = None, sleep: Optional[Callable[[float], Awaitable[None]]] = None) -> T
```

Call `fn` until success or retries exhausted.

`max_retries` is the number of *retries* after the first attempt
(default ALIBI\_CP\_MAX\_RETRIES=3 → up to 4 attempts).

**Parameters**

| Name | Type |
| - | - |
| `fn` | `Callable[[], Awaitable[T]]` |
| `max_retries` | `Optional[int]` |
| `base_ms` | `Optional[float]` |
| `max_ms` | `Optional[float]` |
| `retry_on` | `Optional[Callable[[BaseException], bool]]` |
| `sleep` | `Optional[Callable[[float], Awaitable[None]]]` |

**Returns**

`T`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.