Example #1
0
    async def _try_validator_request(self, message_type, content):
        """Serializes and sends a Protobuf message to the validator.
        Handles timeout errors as needed.
        """
        if isinstance(content, BaseMessage):
            content = content.SerializeToString()

        future = self._stream.send(message_type=message_type, content=content)

        try:
            response = await self._loop.run_in_executor(
                None, future.result, self._timeout)
        except FutureTimeoutError:
            raise errors.ValidatorUnavailable()

        try:
            return response.content
        # Caused by resolving a FutureError on validator disconnect
        except ValidatorConnectionError:
            raise errors.ValidatorUnavailable()
Example #2
0
    def _try_validator_request(self, message_type, content):
        """
        Sends a protobuf message to the validator
        Handles a possible timeout if validator is unresponsive
        """
        if isinstance(content, BaseMessage):
            content = content.SerializeToString()

        future = self._stream.send(message_type=message_type, content=content)

        try:
            response = future.result(timeout=self._timeout)
        except FutureTimeoutError:
            raise errors.ValidatorUnavailable()

        try:
            return response.content
            # the error is caused by resolving a FutureError
            # on validator disconnect.
        except ValidatorConnectionError:
            raise errors.ValidatorUnavailable()
Example #3
0
    def _try_validator_request(self, message_type, content):
        """
        Sends a protobuf message to the validator
        Handles a possible timeout if validator is unresponsive
        """
        timeout = 300

        if isinstance(content, BaseMessage):
            content = content.SerializeToString()

        future = self._stream.send(message_type=message_type, content=content)

        try:
            response = future.result(timeout=timeout)
        except FutureTimeoutError:
            raise errors.ValidatorUnavailable()

        return response.content