subscriber¶
- class litestar.channels.subscriber.Subscriber[原始碼]¶
基底類別:
objectA wrapper around a stream of events published to subscribed channels
- __init__(plugin: ChannelsPlugin, max_backlog: int | None = None, backlog_strategy: BacklogStrategy = 'backoff') None[原始碼]¶
- async iter_events() AsyncGenerator[bytes, None][原始碼]¶
Iterate over the stream of events. If no items are available, block until one becomes available
- run_in_background(on_event: Callable[[bytes], Awaitable[Any]], join: bool = True) AsyncGenerator[None, None][原始碼]¶
Start a task in the background that sends events from the subscriber's stream to
socketas they become available. On exit, it will prevent the stream from accepting new events and wait until the currently enqueued ones are processed. Should the context be left with an exception, the task will be cancelled immediately.