How to use the jsonrpcclient.exceptions.ReceivedNoResponse function in jsonrpcclient

To help you get started, we’ve selected a few jsonrpcclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bcb / jsonrpcclient / test / unit / test_server.py View on Github external
def test_handle_response_request_with_empty_string_response(self):
        response = ''
        with self.assertRaises(exceptions.ReceivedNoResponse):
            self.server._handle_response(response, expected_response=True)
github bcb / jsonrpcclient / test / unit / test_exceptions.py View on Github external
def test_ReceivedNoResponse(self):
        with self.assertRaises(exceptions.ReceivedNoResponse):
            raise exceptions.ReceivedNoResponse
github bcb / jsonrpcclient / test / unit / test_exceptions.py View on Github external
def test_ReceivedNoResponse(self):
        with self.assertRaises(exceptions.ReceivedNoResponse):
            raise exceptions.ReceivedNoResponse
github bcb / jsonrpcclient / jsonrpcclient / proxy.py View on Github external
def handle_response(response_str, expected_response=True):
        """Processes the response from a request"""

        # A response was expected, but none was given?
        if expected_response and not len(response_str):
            raise exceptions.ReceivedNoResponse()

        # Was response given?
        if len(response_str):

            # Attempt to parse the response
            try:
                response_dict = json.loads(response_str)

            except ValueError:
                raise exceptions.ParseError()

            # A response was *not* expected, but one was given? It may not
            # be necessary to raise here. If we receive a response anyway,
            # can't we just ignore it?
            if not expected_response and 'result' in response_dict:
                raise exceptions.InvalidResponse()