Esempio n. 1
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     try:
         self.socket.connect(self.url)
     except zmq.error.ZMQError as ex:
         raise errors.PushPullError(f"The url: {self.url} is not appropriate for a '{self.__class__.__name__}' end") \
             from ex
Esempio n. 2
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     if self.socket_type != zmq.PULL:
         raise errors.PushPullError(
             f"'{self.__class__.__name__}' end instantiated with the wrong socket "
             f"type: {self.socket_type}")
     self.timeout = kwargs.get('timeout', POLLING_TIMEOUT)
     self.poller = zmq.Poller()
     self.poller.register(self.socket, zmq.POLLIN)
Esempio n. 3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        try:
            self.socket.bind(self.url)
        except zmq.error.ZMQError as ex:
            raise errors.PushPullError(
                f"Unable to bind PULL socket with url {self.url}. "
                f"Ensure that the type of url and socket are the correct ones"
            ) from ex
Esempio n. 4
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        if self.socket_type != zmq.PUSH:
            raise errors.PushPullError(
                f"'{self.__class__.__name__}' end instantiated with the wrong socket type: "
                f"{self.socket_type}")

        self.sndhwm = kwargs.get(
            'sndhwm', 1000)  # 1000 is the default value according to zeromq
        self.socket.setsockopt(zmq.SNDHWM, self.sndhwm)
        self.mute_time_out = kwargs.get('time_out', 1)
Esempio n. 5
0
 def __init__(self, url, identity, context=None, s_type=zmq.PUSH, **kwargs):
     if 'ipc://' in url and len(url) > MAX_IPC_URL_LENGTH:
         raise errors.PushPullError(
             f"IPC URL '{url}' cannot have more than {MAX_IPC_URL_LENGTH} characters long"
         )
     self.context = context or zmq.Context()
     self.socket = self.context.socket(s_type)
     self.socket.setsockopt(zmq.LINGER, kwargs.get(
         'linger', -1))  # -1 is the default value according to zeromq
     self.url = url
     self.identity = identity
     self.socket_type = s_type