events¶
- class litestar.events.BaseEventEmitterBackend[源代码]¶
基类:
AbstractAsyncContextManager[BaseEventEmitterBackend],ABCAbstract class used to define event emitter backends.
- __init__(listeners: Sequence[EventListener]) None[源代码]¶
Create an event emitter instance.
- 参数:
listeners¶ -- A list of listeners.
- class litestar.events.EventListener[源代码]¶
基类:
objectDecorator for event listeners
- __call__(fn: AnyCallable) EventListener[源代码]¶
Decorate a callable by wrapping it inside an instance of EventListener.
- 参数:
fn¶ -- Callable to decorate.
- 返回:
An instance of EventListener
- __init__(*event_ids: str) None[源代码]¶
Create a decorator for event handlers.
- 参数:
*event_ids¶ -- The id of the event to listen to or a list of event ids to listen to.
- static wrap_in_error_handler(fn: AsyncAnyCallable) AsyncAnyCallable[源代码]¶
Wrap a listener function to handle errors.
Listeners are executed concurrently in a TaskGroup, so we need to ensure that exceptions do not propagate to the task group which results in any other unfinished listeners to be cancelled, and the receive stream to be closed.
See https://github.com/litestar-org/litestar/issues/2809
- 参数:
fn¶ -- The listener function to wrap.
- class litestar.events.SimpleEventEmitter[源代码]¶
-
Event emitter the works only in the current process
- __init__(listeners: Sequence[EventListener]) None[源代码]¶
Create an event emitter instance.
- 参数:
listeners¶ -- A list of listeners.
- litestar.events.listener¶
EventListener的别名