---
title: health
---

<div class="python-reference">
<a id="fastvideo.entrypoints.streaming.health-functions"></a>
<a id="fastvideo.entrypoints.streaming.health"></a>
<p>Health, readiness, and status routes for streaming servers.</p>
<h2 id="fastvideo.entrypoints.streaming.health.PoolHealth"><code>fastvideo.entrypoints.streaming.health.PoolHealth</code></h2>
<pre class="doc-signature"><code>PoolHealth(total_workers: int, available_workers: int, active_sessions: int, queued_sessions: int = 0)</code></pre>


<h2 id="fastvideo.entrypoints.streaming.health.build_health_router"><code>fastvideo.entrypoints.streaming.health.build_health_router</code></h2>
<pre class="doc-signature"><code>build_health_router(pool: PoolRef = None) -&gt; APIRouter</code></pre>
<p>Build a router exposing streaming liveness/readiness endpoints.</p>
<p><code>pool</code> may be either a concrete pool or a zero-argument callable that
returns the current pool. The callable form lets product servers keep their
own lifespan-managed runtime singleton without adding public global state.</p>
<details><summary>Source</summary><pre><code>def build_health_router(pool: PoolRef = None) -&gt; APIRouter:
    &quot;&quot;&quot;Build a router exposing streaming liveness/readiness endpoints.

    ``pool`` may be either a concrete pool or a zero-argument callable that
    returns the current pool. The callable form lets product servers keep their
    own lifespan-managed runtime singleton without adding public global state.
    &quot;&quot;&quot;
    router = APIRouter()

    @router.get(&quot;/health&quot;)
    @router.get(&quot;/healthz&quot;)
    async def get_healthz() -&gt; dict&#91;str, Any&#93;:
        &quot;&quot;&quot;Liveness probe for process-level health.&quot;&quot;&quot;
        return &#123;
            &quot;status&quot;: &quot;ok&quot;,
            &quot;service&quot;: SERVICE_NAME,
            &quot;ts&quot;: _utc_now_iso(),
        &#125;

    @router.get(&quot;/readyz&quot;)
    async def get_readyz() -&gt; dict&#91;str, Any&#93;:
        &quot;&quot;&quot;Readiness probe for router/load-balancer health checks.&quot;&quot;&quot;
        status_payload = await get_pool_status(pool)
        ready_workers = _ready_worker_count(status_payload)
        return &#123;
            &quot;status&quot;: &quot;ready&quot; if ready_workers &gt; 0 else &quot;warming&quot;,
            &quot;service&quot;: SERVICE_NAME,
            &quot;ready_gpu_workers&quot;: ready_workers,
            &quot;total_gpus&quot;: _as_int(status_payload.get(&quot;total_gpus&quot;)),
            &quot;available_gpus&quot;: _as_int(status_payload.get(&quot;available_gpus&quot;)),
            &quot;warmup_successful_gpus&quot;: _as_int(status_payload.get(&quot;warmup_successful_gpus&quot;)),
            &quot;warmup_failed_gpus&quot;: _as_int(status_payload.get(&quot;warmup_failed_gpus&quot;)),
            &quot;queue_size&quot;: _as_int(status_payload.get(&quot;queue_size&quot;)),
            &quot;ts&quot;: _utc_now_iso(),
        &#125;

    @router.get(&quot;/status&quot;)
    async def get_status() -&gt; dict&#91;str, Any&#93;:
        &quot;&quot;&quot;Get the current status of the GPU pool.&quot;&quot;&quot;
        return await get_pool_status(pool)

    return router</code></pre></details>
<h2 id="fastvideo.entrypoints.streaming.health.get_pool_status"><code>fastvideo.entrypoints.streaming.health.get_pool_status</code></h2>
<pre class="doc-signature"><code>get_pool_status(pool: PoolRef = None) -&gt; dict&#91;str, Any&#93;</code></pre>
<p>Return the generic GPU pool status payload used by <code>/status</code>.</p>
<details><summary>Source</summary><pre><code>async def get_pool_status(pool: PoolRef = None) -&gt; dict&#91;str, Any&#93;:
    &quot;&quot;&quot;Return the generic GPU pool status payload used by ``/status``.&quot;&quot;&quot;
    resolved = _resolve_pool(pool)
    if resolved is None:
        return _zero_pool_status()
    if _has_get_status(resolved):
        return dict(resolved.get_status())
    if _has_health(resolved):
        return _status_from_health(resolved.health())
    return _zero_pool_status()</code></pre></details>
</div>
