mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 14:51:22 +00:00
Refactor reset in StatefulEventHandler
This commit is contained in:
parent
6f16a335db
commit
ad89c8fb57
@ -16,10 +16,7 @@ class StatefulEventHandler(EventHandlerBase):
|
||||
def event_handler_callback(msg_parts):
|
||||
anchor, message = msg_parts
|
||||
if anchor == b'reset':
|
||||
self.generator = None
|
||||
self.unsubscribe_all()
|
||||
self.subscribe(self.anchor)
|
||||
self.subscribe('reset')
|
||||
self.reset()
|
||||
return
|
||||
data_json = json.loads(message)
|
||||
if self.generator is None:
|
||||
@ -36,3 +33,12 @@ class StatefulEventHandler(EventHandlerBase):
|
||||
self.zmq_push_socket.send_multipart(response)
|
||||
|
||||
self.zmq_sub_stream.on_recv(event_handler_callback)
|
||||
|
||||
def unsubscribe_all(self):
|
||||
super().unsubscribe_all()
|
||||
self.subscribe('reset')
|
||||
|
||||
def reset(self):
|
||||
self.generator = None
|
||||
self.unsubscribe_all()
|
||||
self.subscribe(self.anchor)
|
||||
|
Loading…
Reference in New Issue
Block a user