diff --git a/src/event_handlers/event_handler.py b/src/event_handlers/event_handler.py index 9505ff1..b75cdc3 100644 --- a/src/event_handlers/event_handler.py +++ b/src/event_handlers/event_handler.py @@ -6,7 +6,8 @@ from event_handler_base import EventHandlerBase class EventHandler(EventHandlerBase): def __init__(self, anchor, event_handler_function, zmq_context=None): - super().__init__(anchor, event_handler_function, zmq_context) + super().__init__(anchor, zmq_context) + self.event_handler_function = event_handler_function def wrapper(msg_parts, handler): anchor, message = msg_parts diff --git a/src/event_handlers/event_handler_base.py b/src/event_handlers/event_handler_base.py index 04b40e7..37a02da 100644 --- a/src/event_handlers/event_handler_base.py +++ b/src/event_handlers/event_handler_base.py @@ -9,9 +9,8 @@ ioloop.install() class EventHandlerBase: - def __init__(self, anchor, event_handler_function, zmq_context=None): + def __init__(self, anchor, zmq_context=None): self.anchor = anchor - self.event_handler_function = event_handler_function self.zmq_context = zmq_context or zmq.Context.instance() self.zmq_sub_socket = self.zmq_context.socket(zmq.SUB) self.subscriptions = {self.anchor} @@ -33,7 +32,9 @@ class EventHandlerBase: def subscribe(self, anchor): if anchor not in self.subscriptions: self.subscriptions.add(anchor) - self.zmq_sub_socket.setsockopt_string(zmq.SUBSCRIBE, anchor) + self.zmq_sub_socket.setsockopt_string( + zmq.SUBSCRIBE, anchor + ) def unsubscribe(self, anchor): try: diff --git a/src/event_handlers/stateful_event_handler.py b/src/event_handlers/stateful_event_handler.py index 9f3fd38..0b9f6bd 100644 --- a/src/event_handlers/stateful_event_handler.py +++ b/src/event_handlers/stateful_event_handler.py @@ -7,8 +7,9 @@ from event_handler_base import EventHandlerBase class StatefulEventHandler(EventHandlerBase): - def __init__(self, anchor, event_handler, zmq_context=None): - super().__init__(anchor, event_handler, zmq_context) + def __init__(self, anchor, event_handler_function, zmq_context=None): + super().__init__(anchor, zmq_context) + self.event_handler_function = event_handler_function self.generator = None self.subscribe('reset') @@ -36,4 +37,4 @@ class StatefulEventHandler(EventHandlerBase): response = [r.encode('utf-8') for r in (response_anchor, response_data)] self.zmq_push_socket.send_multipart(response) - self.zmq_sub_stream.on_recv(partial(wrapper, handler=event_handler)) + self.zmq_sub_stream.on_recv(partial(wrapper, handler=event_handler_function))