How to use the pyzmq.helloword.src.core.connectors.Connector function in pyzmq

To help you get started, we’ve selected a few pyzmq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zeromq / cookbook / pyzmq / helloword / src / core / connectors.py View on Github external
self._sockt = self._context.socket(zmq.REQ)
        self._sockt.setsockopt(zmq.IDENTITY, self._name)
        self.log = logging.getLogger(__name__)

    def connect(self):
        self.log.info(' try connect to {0} '.format(self._end_point))
        self._sockt.connect(str(self._end_point))
        self.log.info('connected to {0} '.format(self._end_point))

    def send(self, data):
        self._sockt.send(data, copy=False)
        msg = self._sockt.recv()
        self._on_recv(self._sockt, msg)


class QueryHandlerConnector(Connector):

    def __init__(self,  name, end_point, context=None):
        Connector.__init__(self,  name, end_point, context)
github zeromq / cookbook / pyzmq / helloword / src / core / connectors.py View on Github external
self._end_point = end_point

    @abstractmethod
    def connect(self):
        pass

    @abstractmethod
    def _on_recv(self, sock, msg):
        pass

    @abstractmethod
    def send(self, data):
        pass


class CommandConnector(Connector):

    def __init__(self,  name, end_point, context=None):
        Connector.__init__(self,  name, end_point, context)
        self._sockt = self._context.socket(zmq.REQ)
        self._sockt.setsockopt(zmq.IDENTITY, self._name)
        self.log = logging.getLogger(__name__)

    def connect(self):
        self.log.info(' try connect to {0} '.format(self._end_point))
        self._sockt.connect(str(self._end_point))
        self.log.info('connected to {0} '.format(self._end_point))

    def send(self, data):
        self._sockt.send(data, copy=False)
        msg = self._sockt.recv()
        self._on_recv(self._sockt, msg)

pyzmq

Python bindings for 0MQ

BSD-3-Clause
Latest version published 4 months ago

Package Health Score

97 / 100
Full package analysis

Similar packages