Module

_output

Kida template infrastructure and one-shot branded output.

Provides the shared template environment, thread-safe stderr writer, and branded renders for CLI commands (error, info, check, traceback) and access logs. Server lifecycle output (banner, ready, shutdown, reload, worker events) is handled by the dispatch-driven view layer in_state.py.

Functions

_get_env 0
Get or create the kida template environment (thread-safe, lazy).
def _get_env()
_is_pretty 0 bool
Check if we're in pretty (TTY) output mode.
def _is_pretty() -> bool
Returns
bool
_render 2 str
Render a kida template with the given context.
def _render(name: str, **ctx) -> str
Parameters
Name Type Description
name str
**ctx
Returns
str
_write 1 None
Write a line to stderr (thread-safe). Reuses the shared lock from pounce.loggi…
def _write(text: str) -> None

Write a line to stderr (thread-safe).

Reuses the shared lock from pounce.logging so lifecycle output and direct stderr writes (JSON mode, etc.) never interleave under free-threaded Python.

Parameters
Name Type Description
text str
error 5 None
Render a branded error message. Uses the kida template when stderr is a TTY (e…
def error(message: str, *, code: str | None = None, hint: str | None = None, docs_url: str | None = None, diagnostics: list[dict[str, str]] | None = None) -> None

Render a branded error message.

Uses the kida template when stderr is a TTY (even if logging hasn't been configured yet — errors can fire before configure_logging runs). Falls back to plain text when piped.

Parameters
Name Type Description
message str
code str | None Default:None
hint str | None Default:None
docs_url str | None Default:None
diagnostics list[dict[str, str]] | None Default:None
_human_bytes 1 str
Format byte count for human readability.
def _human_bytes(n: int) -> str
Parameters
Name Type Description
n int
Returns
str
_duration_str 1 str
Format duration in human-readable form.
def _duration_str(ms: float) -> str
Parameters
Name Type Description
ms float
Returns
str
access 6 None
Render a pretty-mode access log line via kida template.
def access(method: str, path: str, status: int, bytes_sent: int, duration_ms: float, client: str) -> None
Parameters
Name Type Description
method str
path str
status int
bytes_sent int
duration_ms float
client str
detect_gil_status 0 str
Detect whether the GIL is enabled or disabled.
def detect_gil_status() -> str
Returns
str
probe_optional_dep 1 tuple[bool, str]
Check if an optional dependency is importable and return its version.
def probe_optional_dep(module: str) -> tuple[bool, str]
Parameters
Name Type Description
module str
Returns
tuple[bool, str]
probe_all_optional_deps 0 list[dict]
Probe all optional dependencies, returning status dicts for rendering.
def probe_all_optional_deps() -> list[dict]
Returns
list[dict]
detect_frameworks 0 list[str]
Detect installed ASGI frameworks by attempting imports.
def detect_frameworks() -> list[str]
Returns
list[str]
info_panel 8 None
Render the system info diagnostic panel.
def info_panel(*, version: str, python_version: str, platform_str: str, cpu_count: int, gil_status: str, install_path: str, deps: list[dict], frameworks: list[str]) -> None
Parameters
Name Type Description
version str
python_version str
platform_str str
cpu_count int
gil_status str
install_path str
deps list[dict]
frameworks list[str]
check_results 3 None
Render pre-flight check results.
def check_results(*, version: str, checks: list[dict], all_passed: bool) -> None
Parameters
Name Type Description
version str
checks list[dict]
all_passed bool
_shorten_path 1 str
Shorten a file path for display.
def _shorten_path(filepath: str) -> str
Parameters
Name Type Description
filepath str
Returns
str
_hint_for_crash 1 str
Generate a contextual hint for common crash patterns.
def _hint_for_crash(exc: BaseException) -> str
Parameters
Name Type Description
exc BaseException
Returns
str
branded_traceback 2 None
Render a branded traceback for an unhandled exception.
def branded_traceback(exc: BaseException, *, worker_id: int | None = None) -> None
Parameters
Name Type Description
exc BaseException
worker_id int | None Default:None