diff --git a/lib/tfw/networking/event_handler_connector.py b/lib/tfw/networking/event_handler_connector.py index 67ca7ba..03f2513 100644 --- a/lib/tfw/networking/event_handler_connector.py +++ b/lib/tfw/networking/event_handler_connector.py @@ -8,15 +8,13 @@ from tfw.config import TFWENV from tfw.config.logs import logging from .serialization import serialize_tfw_msg, with_deserialize_tfw_msg -from .zmq_connector_base import ZMQConnectorBase LOG = logging.getLogger(__name__) -class EventHandlerDownlinkConnector(ZMQConnectorBase): - def __init__(self, zmq_context=None): - super(EventHandlerDownlinkConnector, self).__init__(zmq_context) - self._zmq_pull_socket = self._zmq_context.socket(zmq.PULL) +class EventHandlerDownlinkConnector(): + def __init__(self): + self._zmq_pull_socket = zmq.Context.instance().socket(zmq.PULL) self._zmq_pull_socket.setsockopt(zmq.RCVHWM, 0) self._zmq_pull_stream = ZMQStream(self._zmq_pull_socket) address = f'tcp://*:{TFWENV.RECEIVER_PORT}' @@ -31,10 +29,9 @@ class EventHandlerDownlinkConnector(ZMQConnectorBase): self._zmq_pull_stream.close() -class EventHandlerUplinkConnector(ZMQConnectorBase): - def __init__(self, zmq_context=None): - super(EventHandlerUplinkConnector, self).__init__(zmq_context) - self._zmq_pub_socket = self._zmq_context.socket(zmq.PUB) +class EventHandlerUplinkConnector(): + def __init__(self): + self._zmq_pub_socket = zmq.Context.instance().socket(zmq.PUB) self._zmq_pub_socket.setsockopt(zmq.SNDHWM, 0) address = f'tcp://*:{TFWENV.PUBLISHER_PORT}' self._zmq_pub_socket.bind(address) @@ -48,6 +45,10 @@ class EventHandlerUplinkConnector(ZMQConnectorBase): class EventHandlerConnector(EventHandlerDownlinkConnector, EventHandlerUplinkConnector): + def __init__(self): + EventHandlerDownlinkConnector.__init__(self) + EventHandlerUplinkConnector.__init__(self) + def close(self): EventHandlerDownlinkConnector.close(self) EventHandlerUplinkConnector.close(self) diff --git a/lib/tfw/networking/server_connector.py b/lib/tfw/networking/server_connector.py index c0e2bf1..da84289 100644 --- a/lib/tfw/networking/server_connector.py +++ b/lib/tfw/networking/server_connector.py @@ -11,15 +11,13 @@ from tfw.config.logs import logging from .scope import Scope from .serialization import serialize_tfw_msg, with_deserialize_tfw_msg -from .zmq_connector_base import ZMQConnectorBase LOG = logging.getLogger(__name__) -class ServerDownlinkConnector(ZMQConnectorBase): - def __init__(self, zmq_context=None): - super(ServerDownlinkConnector, self).__init__(zmq_context) - self._zmq_sub_socket = self._zmq_context.socket(zmq.SUB) +class ServerDownlinkConnector(): + def __init__(self): + self._zmq_sub_socket = zmq.Context.instance().socket(zmq.SUB) self._zmq_sub_socket.connect(f'tcp://localhost:{TFWENV.PUBLISHER_PORT}') self._zmq_sub_socket.setsockopt(zmq.RCVHWM, 0) self._zmq_sub_stream = ZMQStream(self._zmq_sub_socket) @@ -35,10 +33,9 @@ class ServerDownlinkConnector(ZMQConnectorBase): self._zmq_sub_stream.close() -class ServerUplinkConnector(ZMQConnectorBase): - def __init__(self, zmq_context=None): - super(ServerUplinkConnector, self).__init__(zmq_context) - self._zmq_push_socket = self._zmq_context.socket(zmq.PUSH) +class ServerUplinkConnector(): + def __init__(self): + self._zmq_push_socket = zmq.Context.instance().socket(zmq.PUSH) self._zmq_push_socket.connect(f'tcp://localhost:{TFWENV.RECEIVER_PORT}') self._zmq_push_socket.setsockopt(zmq.SNDHWM, 0) @@ -51,6 +48,10 @@ class ServerUplinkConnector(ZMQConnectorBase): class ServerConnector(ServerUplinkConnector, ServerDownlinkConnector): + def __init__(self): + ServerUplinkConnector.__init__(self) + ServerDownlinkConnector.__init__(self) + def close(self): ServerUplinkConnector.close(self) ServerDownlinkConnector.close(self) diff --git a/lib/tfw/networking/zmq_connector_base.py b/lib/tfw/networking/zmq_connector_base.py deleted file mode 100644 index 47a850e..0000000 --- a/lib/tfw/networking/zmq_connector_base.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (C) 2018 Avatao.com Innovative Learning Kft. -# All Rights Reserved. See LICENSE file for details. - -import zmq - - -class ZMQConnectorBase: - def __init__(self, zmq_context=None): - self._zmq_context = zmq_context or zmq.Context.instance()