iot_firmware.event.handler
Module in charge of handling function event subscriptions.
Classes
|
Class that handles Events. |
Poison pill used to stop the workers gracefully. |
- class iot_firmware.event.handler.EventHandler(num_workers: int = 10, buffer_maxsize: int = 100, worker_timeout_seconds: float = 2, state: EventHandlerState = EventHandlerState.IDLE)[source]
Class that handles Events.
It is in charge to execute all subscribed functions to an Event.
Basic usage.
>>> event_handler = EventHandler() >>> event_handler.state.name 'IDLE'
- num_workers: int = 10
- buffer_maxsize: int = 100
- worker_timeout_seconds: float = 2
- state: EventHandlerState = 1
- subscribe(event_class: Type[Event], fn: Callable) None[source]
Subscribes a function to an EventType.
- Parameters
event_class – event class that contains an event type
fn – function that is going to be called with the event object
- unsubscribe(event_class: Type[Event], fn: Callable) None[source]
Unsubscribes a function to an EventType.
- Parameters
event_class – event class that contains an event type
fn – function that is going to be called with the event object