yera.runtime.publisher
Publish rendered HTML fragments to live or replay consumers.
HTMX handlers render strings through a common publisher boundary. A live publisher transfers fragments from synchronous handler calls into an asynchronous consumer. A replay publisher records the same fragments in memory so stored sessions can be rendered without opening a live stream.
Symbols
BasePublisher
ABCDefine fragment, pause, and completion signals for web rendering.
Concrete publishers may deliver fragments asynchronously or collect them synchronously, but expose the same interface to HTMX handlers.
Methods
BasePublisher.push
push(
chunk: str,
) → NonePush a fragment to the sink.
Parameters
The string fragment to be published.
BasePublisher.push_eof
push_eof() → NoneSignal the end of the fragment stream.
BasePublisher.push_pause
push_pause() → NoneSignal a temporary pause without closing the stream.
Publisher
BasePublisherTransfer rendered fragments safely into an asynchronous consumer.
Synchronous handler calls may publish from another thread. Each operation
is therefore scheduled onto the owning event loop. Consumers iterate
stream() until completion; pause signals are yielded so the caller can
suspend a response without closing the publisher. Completion remains
observable by later consumers.
Methods
Publisher.__init__
__init__(
loop: asyncio.AbstractEventLoop | None = None,
)Initialize an asynchronous fragment publisher.
Parameters
The event loop to use. If None, the running loop is retrieved.
Publisher.push
push(
chunk: str,
) → NonePush a fragment onto the asynchronous queue from any thread.
Parameters
The string fragment to publish.
Publisher.push_eof
push_eof() → NoneSignal completion from any thread.
Publisher.push_pause
push_pause() → NoneSignal a temporary pause from any thread.
Publisher.stream
stream() → AsyncIterator[str | object]Yield fragments and pause signals until completion.
ReplayPublisher
BasePublisherCollect rendered fragments synchronously for stored-session replay.
Replay consumes a bounded event sequence, so fragments are appended to
frames and pause or completion signals require no queue sentinel.
Methods
ReplayPublisher.__init__
__init__() → NoneInitialize an empty replay frame collection.
ReplayPublisher.push
push(
chunk: str,
) → NoneAppend a fragment to the replay frame collection.
Parameters
The string fragment to collect.
ReplayPublisher.push_eof
push_eof() → NoneNo-op: replay collects a bounded list, no EOF sentinel.
ReplayPublisher.push_pause
push_pause() → NoneNo-op: replay supplies its own close after the collected frames.
WebRenderContext
Provide the web transport required by HTMX handlers.
Fields
Destination for rendered HTML fragments.
Endpoint used by interactive fragments to submit responses.
Methods
WebRenderContext.__init__
__init__(
publisher: BasePublisher,
input_url: str,
) → None