Handlers¶
diffusion.handlers
¶
Base module for various event handlers.
Handler
¶
Bases: Protocol
Protocol for event handlers implementation.
handle(event: str, kwargs: typing.Any) -> typing.Any
async
¶
Implements handling of the given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event |
str
|
The event identifier. |
required |
**kwargs |
typing.Any
|
Additional arguments. |
{}
|
UnknownHandlerError
¶
Bases: exceptions.DiffusionError
Raised when a requested handler key has not been registered in the session.
SimpleHandler
¶
AbstractHandlerSet
¶
Bases: Handler
, typing.Iterable[Handler]
handle(event: str = '', kwargs: typing.Any) -> typing.Any
async
¶
Implements handling of the given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event |
str
|
The event identifier. |
''
|
**kwargs |
typing.Any
|
Additional arguments. |
{}
|
Returns:
Type | Description |
---|---|
typing.Any
|
Aggregated list of returned values. |
HandlerSet
¶
Bases: set
, AbstractHandlerSet
A collection of handlers to be invoked together.
EventStreamHandler
¶
Bases: Handler
Generic handler of event streams.
Each keyword argument is a callable which will be converted to coroutine and awaited to handle the event matching the argument keyword.
handle(event: str, kwargs: typing.Any)
async
¶
Implements handling of the given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event |
str
|
The event identifier. |
required |
**kwargs |
typing.Any
|
Additional arguments. |
{}
|