Receive subscribed messages and dispatch decoded objects to handlers. More...
Public Member Functions | |
| None | __init__ (self, SubscriberIf subscriber, *Executor|None executor=None, int max_workers=4, ErrorHandler|None error_handler=None) |
| Create a dispatcher around one transport subscriber. | |
| None | register (self, str topic, Decoder decoder, Handler handler) |
| Subscribe and register one decoder/handler pair for a topic. | |
| None | start (self) |
| Start the single subscriber receive thread after registration is complete. | |
| None | close (self) |
| Stop reception before shutting down handler workers. | |
Receive subscribed messages and dispatch decoded objects to handlers.
Exactly one receiver thread owns the SubscriberIf. Handler execution is delegated to a shared Executor so slow consumers do not block reception. Register all topics before calling start(). Handlers run on executor worker threads and therefore must not directly mutate thread-affine UI toolkits.
| None messaging.message_dispatcher.MessageDispatcher.__init__ | ( | self, | |
| SubscriberIf | subscriber, | ||
| *Executor | None | executor = None, |
||
| int | max_workers = 4, |
||
| ErrorHandler | None | error_handler = None |
||
| ) |
Create a dispatcher around one transport subscriber.
| subscriber | Transport-independent subscriber owned by the receive loop. |
| executor | Optional executor used for decoded message handlers. |
| max_workers | Worker count used when the dispatcher creates its executor. |
| error_handler | Optional callback receiving topic and dispatch exceptions. |
| None messaging.message_dispatcher.MessageDispatcher.close | ( | self | ) |
Stop reception before shutting down handler workers.
The receive thread must be fully stopped before the owned executor is shut down. Otherwise a message received during teardown can race an executor shutdown and attempt to submit work after shutdown has begun.