mbr / tinyrpc

A compact, modular transport and protocol agnostic RPC library. Does jsonrpc v2.
https://tinyrpc.readthedocs.org
MIT License
156 stars 53 forks source link

AttributeError in tinyrpc 1.0.0 #73

Closed drnextgis closed 5 years ago

drnextgis commented 5 years ago

Version 0.9.4 returns RPCError in case of exception but in a recent one I'm getting the following issue:

In [3]: remote_server.reverse_string('Hello, World!')                                                                                                                                                               
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-95dc71bed420> in <module>
----> 1 remote_server.reverse_string('Hello, World!')

~/satellogic/env-nkappa-rpc/lib/python3.6/site-packages/tinyrpc/client.py in <lambda>(*args, **kwargs)
    161         """
    162         proxy_func = lambda *args, **kwargs: self.client.call(
--> 163             self.prefix + name, args, kwargs, one_way=self.one_way
    164         )
    165         return proxy_func

~/satellogic/env-nkappa-rpc/lib/python3.6/site-packages/tinyrpc/client.py in call(self, method, args, kwargs, one_way)
     75         req = self.protocol.create_request(method, args, kwargs, one_way)
     76 
---> 77         rep = self._send_and_handle_reply(req, one_way)
     78 
     79         if one_way:

~/satellogic/env-nkappa-rpc/lib/python3.6/site-packages/tinyrpc/client.py in _send_and_handle_reply(self, req, one_way, transport, no_exception)
     54             if hasattr(self.protocol, 'raise_error') and callable(
     55                     self.protocol.raise_error):
---> 56                 response = self.protocol.raise_error(response.error)
     57             else:
     58                 raise RPCError(

~/satellogic/env-nkappa-rpc/lib/python3.6/site-packages/tinyrpc/protocols/jsonrpc.py in raise_error(self, error)
    659             ``data`` property.
    660         """
--> 661         exc = JSONRPCError(error.error)
    662         if self.raises_errors:
    663             raise ex

AttributeError: 'str' object has no attribute 'error'

Called function is:

@dispatcher.public
def reverse_string(s):
    raise Exception('Not yet implemented')
drnextgis commented 5 years ago

Moreover this variable is not defined: https://github.com/mbr/tinyrpc/blob/8fb9ec8ef90293a6fbccf652229840c3753a9ea6/tinyrpc/protocols/jsonrpc.py#L663

lnoor commented 5 years ago

Thanks for reporting. I will look into it shortly. It does show that there is a problem: I am currently not using tinyrpc myself anymore and the tests are insufficient.

As you are clearly using tinyrpc in real life applications would you be willing to evaluate future release candidates? That would help prevent irritating problems like you report now.

drnextgis commented 5 years ago

Thank you for your quick reply. Yes we are using tinyrpc in real life app and this is the first error that popped up since we started to use it. I will be happy to help with evaluating future release candidates.

lnoor commented 5 years ago

Solved in release 1.0.1

drnextgis commented 5 years ago

Cool. Thanks!