Exemplo n.º 1
0
    def _eval_dct(self, dct):
        """Takes approximately 0.2-0.3 ms per call if HOST=='localhost'."""
        self.s.send(dumper(dct))

        acquiring_image = dct['attr_name'] == 'getImage'

        if acquiring_image and not self.use_shared_memory:
            response = self.s.recv(self._imagebufsize)
        else:
            response = self.s.recv(self._bufsize)

        if response:
            status, data = loader(response)

        if self.use_shared_memory and acquiring_image:
            data = self.get_data_from_shared_memory(**data)

        if status == 200:
            return data

        elif status == 500:
            error_code, args = data
            raise exception_list.get(error_code, TEMCommunicationError)(*args)

        else:
            raise ConnectionError(f'Unknown status code: {status}')
Exemplo n.º 2
0
    def _eval_dct(self, dct):
        """Takes approximately 0.2-0.3 ms per call if HOST=='localhost'."""

        self.s.send(dumper(dct))
        response = self.s.recv(self._bufsize)
        if response:
            status, data = loader(response)

        if status == 200:
            return data

        elif status == 500:
            error_code, args = data
            raise exception_list.get(error_code, TEMCommunicationError)(*args)

        else:
            raise ConnectionError(f'Unknown status code: {status}')