Event Stream Service
EventStreamService — owns the anyio memory channel for event routing.
EventStreamService
Bases: Resource
Owns the anyio memory channel that routes events from producers to the bus.
This is a Resource (no background task). It creates the send/receive streams at construction time and tears them down on shutdown.
Source code in src/hassette/core/event_stream_service.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
receive_stream: MemoryObjectReceiveStream[Event[Any]]
property
The receive end of the event stream, for BusService to clone.
event_streams_closed: bool
property
Check if both streams are closed.
on_initialize() -> None
async
Signal readiness — streams are created synchronously in init.
Source code in src/hassette/core/event_stream_service.py
34 35 36 | |
send_event(event: Event[Any]) -> None
async
Send an event to the bus via the memory channel.
Source code in src/hassette/core/event_stream_service.py
47 48 49 | |
close_streams() -> None
async
Close both streams. Called by Hassette._on_children_stopped() after all children have stopped.
Idempotent — safe to call multiple times (Hassette.shutdown() finally block calls this as a fallback on timeout paths).
Source code in src/hassette/core/event_stream_service.py
56 57 58 59 60 61 62 63 64 65 | |