Skip to main content

BackgroundStatus

Shape of the dict returned by get_background_status() on both the deployment controller (from init_latest_deployment) and the evaluation results controller (from 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

{
    "stopped": bool,
    "consecutive_failures": int,
    "last_error": Optional[str],
    "last_refreshed": datetime,
}

Fields

FieldTypeDescription
stoppedboolTrue if the background polling loop has stopped (either manually via await controller.stop() or due to max_continuous_failures being reached).
consecutive_failuresintNumber of consecutive refresh failures since the last successful poll. Resets to 0 on a successful refresh.
last_errorOptional[str]Message from the most recent error, or None if the last refresh succeeded.
last_refresheddatetimeUTC timestamp of the last refresh attempt.

Usage

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:
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