realtime.signal_stream

Page actions AI-ready formats and sharing
Open LLM text
Share with AI
Ask Claude Ask ChatGPT Ask Gemini Ask Copilot

The single/_chirp/livemerge stream for signals.

One framework route, auto-registered at freeze when any signal exists, returns anEventStreamwhose generator merges every signal source + every imperativeapp.emitinto one…

The single/_chirp/livemerge stream for signals.

One framework route, auto-registered at freeze when any signal exists, returns anEventStreamwhose generator merges every signal source + every imperativeapp.emitinto one typed update stream. The SSE boundary frames each update as a named event for htmx 2 or as an unnamed targeted<hx-partial>for htmx 4.

Two producer paths feed the one stream:

  1. Push / derivedemit() (and the derived cascade) fan a markerChangeEventonto the bus. The merge generator drains the bus, reads the latest cached value, renders it, and yields one typed update.
  2. Async sources — a@app.signal(source=...)async generator is pumped by a per-source background task that callsregistry.emitfor each yielded value, so it rides the exact same bus + cache path (coalescing-latest, derived cascade, render isolation) as push emits.

Render happens inrender_for_emit() inside the per-event boundary (oneNonereturn skips that event); a render failure never kills the shared connection. Reading the latest cached value on drain gives coalescing-latest semantics for free — a bus drop under back-pressure is reconciled by the next read.

realtime.signal_stream

Name Type Default Description
type
qualified_name
element_type
description
source_file
line_number
is_autodoc
autodoc_element
_autodoc_template
_autodoc_url_path
_autodoc_page_type
title
doc_content_hash

Symbols on this page

make_signal_stream
function
def make_signal_stream(registry: SignalRegistry, names: tuple[str, ...], *, audience_key: str = '') -> EventStream

Build the/_chirp/live merge EventStreamfor names.

Subscribes to every requested signal's bus scope, pumps each primary signal's asyncsourceas a background task, and yields one client-neutral update per change. Thehandle_sse() per-event boundary isolates render failures; cleanup unsubscribes + cancels source tasks.

Parameters

Name Type Default Description
registry SignalRegistry
names tuple[str, ...]
audience_key str ''
make_signal_pending_route
function
def make_signal_pending_route(registry: SignalRegistry) -> PendingRoute

Return thePendingRoute for the single merged /_chirp/livestream.

The handler reads?topics=a,bto scope the stream to the signals bound on the originating page; an absent/empty/unknowntopicssubscribes to every registered signal.referenced=Truemarks it framework-internal (not block-addressable), mirroring other SSE routes.

Parameters

Name Type Default Description
registry SignalRegistry

View source · /home/runner/work/chirp/chirp/site/../src/chirp/realtime/signal_stream.py:1