Module

_health

Built-in health check endpoint.

Responds to GET and HEAD requests at the configuredhealth_check_pathbefore the request reaches the ASGI application. Returns a JSON payload with server status, uptime, active connections, and worker identity.

Skips access logging by default (health checks are noisy in production).

Functions

build_health_response 3 tuple[int, list[tuple[by…
Build a health check response. When *draining* is True the response uses HTTP …
def build_health_response(*, worker_id: int, active_connections: int, draining: bool = False) -> tuple[int, list[tuple[bytes, bytes]], bytes]

Build a health check response.

When draining is True the response uses HTTP 503 with {"status": "draining", ...}so load balancers stop routing new traffic while the worker finishes in-flight work.

Parameters
Name Type Description
worker_id int
active_connections int
draining bool Default:False
Returns
tuple[int, list[tuple[bytes, bytes]], bytes]