Repository: tomerfiliba-org/rpyc

Issue #350: numpy TypeError and obtain/deliver usability
Created: 2019-10-07T16:28:36Z
Environment

rpyc latest (4.1.2)
python 3.6.7
operating system: Ubuntu 18.04

Minimal example
Server:
import rpyc
import numpy as np

from rpyc.utils.server import OneShotServer

class HelloService(rpyc.Service):
    def get(self):
        return np.random.rand(3, 3)

if __name__ == "__main__":
    rpyc.lib.setup_logger()
    server = OneShotServer(HelloService, port=12345,
                           protocol_config={'allow_all_attrs': True, 'allow_pickle': True})
    server.start()
Client:
import rpyc
import numpy as np

if __name__ == "__main__":
    c = rpyc.connect("localhost", 12345)
    arr = c.root.get()
    arr.astype(np.uint32)  # generates TypeError
traceback obtained:
Traceback (most recent call last):
  File "/home/gregory.starck/projects/pyro/rpyc_cli.py", line 7, in <module>
    arr.astype(np.uint32)  # generates TypeError
  File "/home/gregory.starck/.virtualenvs/autocooler/lib/python3.6/site-packages/rpyc/core/netref.py", line 247, in __call__
    return syncreq(_self, consts.HANDLE_CALL, args, kwargs)
  File "/home/gregory.starck/.virtualenvs/autocooler/lib/python3.6/site-packages/rpyc/core/netref.py", line 76, in syncreq
    return conn.sync_request(handler, proxy, *args)
  File "/home/gregory.starck/.virtualenvs/autocooler/lib/python3.6/site-packages/rpyc/core/protocol.py", line 464, in sync_request
    return self.async_request(handler, *args, timeout=timeout).value
  File "/home/gregory.starck/.virtualenvs/autocooler/lib/python3.6/site-packages/rpyc/core/async_.py", line 102, in value
    raise self._obj
TypeError: data type not understood

========= Remote Traceback (1) =========
Traceback (most recent call last):
  File "/home/gregory.starck/.virtualenvs/autocooler/lib/python3.6/site-packages/rpyc/core/protocol.py", line 323, in _dispatch_request
    res = self._HANDLERS[handler](self, *args)
  File "/home/gregory.starck/.virtualenvs/autocooler/lib/python3.6/site-packages/rpyc/core/protocol.py", line 585, in _handle_call
    return obj(*args, **dict(kwargs))
TypeError: data type not understood


Process finished with exit code 1

was expecting statement to succeed.
Is there anything I'm doing wrong ?

Duplicate issue #510: Question: passing complicated values by value from server to client?
Created: 2022-10-18T18:27:17Z
I need to pass a non-trivial value from a server to a client (such as a Python dict or a list). However, on the client-side, I will receive a netref by default for such values.
One way to achieve this is calling rpyc.utils.classic.obtain() on the client-side. However, this has two downsides. First, pickling needs to be enabled for the server. And second, this places the decision solely on the side of the client, whereas the server may want to decouple its local value from the remote side as a matter of policy (i.e. always do a pass-by-value rather than a pass-by-netref); and it may want to do this without explicitly enabling client-initiated pickling requests.
Is there a way to achieve this behavior?
If not, I'd like to mark this as a feature request; i.e. a way for the server to return a value that, at the client side, will also be represented as a value, rather than a netref.

Closing comment (2022-10-31T03:14:08Z): Agreed. #393 was a dup of #350 and so is this issue. While RPyC aims to be transparent, "unexpected" behavior from CPython seems to be a consistent pain point.
Of course, documentation and making RPyC easy to use are important. So, I always welcome PRs!