def imageReceived(self, data: bytes):
    try:
        img_data = numpy.reshape(numpy.frombuffer(data, dtype=numpy.uint8), newshape=self._image_shape)
        self._image_callback.callback(img_data)
    except (AttributeError, defer.AlreadyCalledError) as e:
        pass
    except Exception as e:
        try:
            self._image_callback.errback(e)
        except defer.AlreadyCalledError:
            pass
def imageReceived(self, data: bytes):
    try:
        img_data = numpy.reshape(numpy.frombuffer(data, dtype=numpy.uint8), newshape=self._image_shape)
        self._image_callback.callback(img_data)
    except (AttributeError, defer.AlreadyCalledError) as e:
        pass
    except Exception as e:
        try:
            self._image_callback.errback(e)
        except defer.AlreadyCalledError:
            pass