mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 08:11:32 +00:00
Remove unnecessary partial magic from EventHandler
This commit is contained in:
parent
f995aae318
commit
3164a760a1
@ -1,5 +1,4 @@
|
|||||||
import json
|
import json
|
||||||
from functools import partial
|
|
||||||
|
|
||||||
from event_handler_base import EventHandlerBase
|
from event_handler_base import EventHandlerBase
|
||||||
|
|
||||||
@ -9,11 +8,11 @@ class EventHandler(EventHandlerBase):
|
|||||||
super().__init__(anchor, zmq_context)
|
super().__init__(anchor, zmq_context)
|
||||||
self.event_handler_function = event_handler_function
|
self.event_handler_function = event_handler_function
|
||||||
|
|
||||||
def event_handler_callback(msg_parts, handler_func):
|
def event_handler_callback(msg_parts):
|
||||||
anchor, message = msg_parts
|
anchor, message = msg_parts
|
||||||
data_json = json.loads(message)
|
data_json = json.loads(message)
|
||||||
response = handler_func(data_json, self)
|
response = self.event_handler_function(data_json, self)
|
||||||
encoded_response = json.dumps(response).encode('utf-8')
|
encoded_response = json.dumps(response).encode('utf-8')
|
||||||
self.zmq_push_socket.send_multipart([anchor, encoded_response])
|
self.zmq_push_socket.send_multipart([anchor, encoded_response])
|
||||||
|
|
||||||
self.zmq_sub_stream.on_recv(partial(event_handler_callback, handler_func=event_handler_function))
|
self.zmq_sub_stream.on_recv(event_handler_callback)
|
||||||
|
Loading…
Reference in New Issue
Block a user