> ## Documentation Index
> Fetch the complete documentation index at: https://www.adaline.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# BackgroundStatus

# BackgroundStatus

Shape of the dict returned by `get_background_status()` on both the deployment controller (from [`init_latest_deployment`](https://www.adaline.ai/docs/reference/sdk/v2/python/classes/adaline#init_latest_deployment)) and the evaluation results controller (from [`init_evaluation_results`](https://www.adaline.ai/docs/reference/sdk/v2/python/classes/adaline#init_evaluation_results)). Tells you whether the background polling loop is healthy, when it last succeeded, and what the most recent error (if any) was.

## Shape

```python theme={null}
{
    "stopped": bool,
    "consecutive_failures": int,
    "last_error": Optional[str],
    "last_refreshed": datetime,
}
```

## Fields

| Field | Type | Description |
| - | - | - |
| `stopped` | `bool` | `True` if the background polling loop has stopped (either manually via `await controller.stop()` or due to `max_continuous_failures` being reached). |
| `consecutive_failures` | `int` | Number of consecutive refresh failures since the last successful poll. Resets to `0` on a successful refresh. |
| `last_error` | `Optional[str]` | Message from the most recent error, or `None` if the last refresh succeeded. |
| `last_refreshed` | `datetime` | UTC timestamp of the last refresh attempt. |

## Usage

```python theme={null}
from adaline.main import Adaline

adaline = Adaline()

controller = await adaline.init_latest_deployment(
    prompt_id="prompt_abc123",
    deployment_environment_id="environment_abc123",
)

# Snapshot current health
status = controller.get_background_status()
print(status["stopped"], status["consecutive_failures"], status["last_error"])
```

### Health monitoring

Use `get_background_status()` in a periodic health check to detect degraded state:

```python theme={null}
import asyncio

async def health_loop(controller):
    while True:
        status = controller.get_background_status()
        if status["stopped"]:
            print("Background refresh stopped — deployments are stale")
            break
        if status["consecutive_failures"] >= 3:
            print(f"Deployment refresh degraded: {status['consecutive_failures']} failures. "
                  f"Last error: {status['last_error']}")
        await asyncio.sleep(30)
```

## See Also

* [Adaline.init\_latest\_deployment](https://www.adaline.ai/docs/reference/sdk/v2/python/classes/adaline.md#init_latest_deployment)
* [Adaline.init\_evaluation\_results](https://www.adaline.ai/docs/reference/sdk/v2/python/classes/adaline.md#init_evaluation_results)


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