MessageDispatcher
Class to dispatch messages to observers. It has a built in buffer to merge messages and dispatch them in a single call to the observers.
:return: description :rtype: type
Attributes
interval_time_dispatched_buffer: float
interval_time_merging_message: float
message_level: MessageLevel
prefix: str
Functions
Initialize self. See help(type(self)) for accurate signature.
Name | Type | Default value | Description |
---|---|---|---|
interval_time_merging_message | float | 0.1 | |
interval_time_dispatched_buffer | int | 1 | |
log_level | MessageLevel | INFO | |
prefix | str | ||
parent_dispatcher | MessageDispatcher |
Attach the listener method and return an id to detach it later
Name | Type | Default value | Description |
---|---|---|---|
observer | MessageObserver |
Attach a progress bar to update task messages when a message is sent. return an id to detach it later
Name | Type | Default value | Description |
---|---|---|---|
progress_bar | ProgressBar |
ProgressBarMessageObserver |
Create a sub dispatcher with the same configuration as the current dispatcher. The message will be forwarded to the parent dispatcher after prefix and log level modification. This is useful to override the prefix or the log level for a specific part of the code without affecting the parent dispatcher.
Name | Type | Default value | Description |
---|---|---|---|
log_level | Optional | ||
prefix | Optional |
Name | Type | Default value | Description |
---|---|---|---|
observer | MessageObserver |
bool |
Trigger a debug in each subscriber.
Name | Type | Default value | Description |
---|---|---|---|
message | str |
Trigger a error in each subscriber.
Name | Type | Default value | Description |
---|---|---|---|
message | str |
Trigger an info in each subscriber.
Name | Type | Default value | Description |
---|---|---|---|
message | str |
Trigger a message in each subscriber.
Name | Type | Default value | Description |
---|---|---|---|
message | DispatchedMessage |
Trigger an update in each subscriber.
Name | Type | Default value | Description |
---|---|---|---|
progress | float | ||
message | str |
Trigger a success in each subscriber.
Name | Type | Default value | Description |
---|---|---|---|
message | str |
Trigger a warning in each subscriber.
Name | Type | Default value | Description |
---|---|---|---|
message | str |