Exemplo n.º 1
0
    def _get_reply(self, request, timeout=100):
        if not self._connected:
            return

        poll = self.poller
        client = self._sock
        try:
            client.send(request)
        except Exception:
            return

        socks = dict(poll.poll(timeout))
        if socks.get(client) == zmq.POLLIN:
            reply = client.recv()
            return reply

        else:
            client.setsockopt(zmq.LINGER, 0)
            client.close()
            poll.unregister(client)

            self._no_connection_cnt += 1
            if self._no_connection_cnt > 5:
                self._connected = False
                p = os.path.join(os.path.dirname(__file__), 'no_connection.jpg')
                self._cached_image = Image.new_frame(p,
                                                swap_rb=True)
            else:
                self.reset_connection(clear_connection_count=False)
                return self._get_reply(request, timeout)
Exemplo n.º 2
0
    def _get_reply(self, request, timeout=100):
        if not self._connected:
            return

        poll = self.poller
        client = self._sock
        try:
            client.send(request)
        except Exception:
            return

        socks = dict(poll.poll(timeout))
        if socks.get(client) == zmq.POLLIN:
            reply = client.recv()
            return reply

        else:
            client.setsockopt(zmq.LINGER, 0)
            client.close()
            poll.unregister(client)

            self._no_connection_cnt += 1
            if self._no_connection_cnt > 5:
                self._connected = False
                p = os.path.join(os.path.dirname(__file__), 'no_connection.jpg')
                self._cached_image = Image.new_frame(p,
                                                swap_rb=True)
            else:
                self.reset_connection(clear_connection_count=False)
                return self._get_reply(request, timeout)
Exemplo n.º 3
0
 def _image_path_changed(self):
     if self.image_path:
         self._cached_image = Image.new_frame(self.image_path, swap_rb=True)
Exemplo n.º 4
0
 def _image_path_changed(self):
     if self.image_path:
         self._cached_image = Image.new_frame(self.image_path, swap_rb=True)