From 9760db7c5ceade937aede9bd99a39a242a3218f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Mon, 29 Jan 2018 16:02:52 +0100 Subject: [PATCH] Work out multiple inheritance in event_handler_connector.py --- src/app/event_handler_connector.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/app/event_handler_connector.py b/src/app/event_handler_connector.py index 6c29039..95400bf 100644 --- a/src/app/event_handler_connector.py +++ b/src/app/event_handler_connector.py @@ -12,7 +12,7 @@ ioloop.install() class EventHandlerDownlinkConnector(ZMQConnectorBase): def __init__(self, zmq_context=None): - super().__init__(zmq_context) + super(EventHandlerDownlinkConnector, self).__init__(zmq_context) self._zmq_pull_socket = self._zmq_context.socket(zmq.PULL) self._zmq_pull_stream = ZMQStream(self._zmq_pull_socket) address = 'tcp://*:{}'.format(RECEIVER_PORT) @@ -22,7 +22,7 @@ class EventHandlerDownlinkConnector(ZMQConnectorBase): class EventHandlerUplinkConnector(ZMQConnectorBase): def __init__(self, zmq_context=None): - super().__init__(zmq_context) + super(EventHandlerUplinkConnector, self).__init__(zmq_context) self._zmq_pub_socket = self._zmq_context.socket(zmq.PUB) address = 'tcp://*:{}'.format(PUBLISHER_PORT) self._zmq_pub_socket.bind(address) @@ -31,19 +31,16 @@ class EventHandlerUplinkConnector(ZMQConnectorBase): class EventHandlerConnector(EventHandlerDownlinkConnector, EventHandlerUplinkConnector): def __init__(self, zmq_context=None): - self.downlink = EventHandlerDownlinkConnector(zmq_context) - self.uplink = EventHandlerUplinkConnector(zmq_context) - #EventHandlerDownlinkConnector.__init__(self, zmq_context) # TODO: solve this with multiple inheritance - #EventHandlerUplinkConnector.__init__(self, zmq_context) + super(EventHandlerConnector, self).__init__(zmq_context) def register_callback(self, callback): - self.downlink._zmq_pull_stream.on_recv(callback) + self._zmq_pull_stream.on_recv(callback) def send_message(self, message: str, anchor: str = None): if not anchor: anchor = parse_anchor_from_message(message) encoded_message = [part.encode('utf-8') for part in (anchor, message)] - self.uplink._zmq_pub_socket.send_multipart(encoded_message) + self._zmq_pub_socket.send_multipart(encoded_message) ehc = EventHandlerConnector()