5

I use xmlrpc.server to build a server and use pickle.dumps() to pickling some data. Then I use xmlrpc.client to build a client and use pickle.loads() to unpickle this data.

## server
server = SimpleXMLRPCServer(('0.0.0.0', 5005), allow_none=True)
# in _dispatch method:
result = perform_stuff()
return pickle.dumps(result)

## client
proxy = ServerProxy(f'http://{host}:{port}', allow_none=True)
result = proxy.make_rpc()
return pickle.loads(result.data)

However, I counter the following problems:

I don't know the difference between the bytes-like object and 'Binary'

I try to use bytes(ret) to solve this problem, but it has another one

Mazyod
  • 22,319
  • 10
  • 92
  • 157
lxg_april
  • 61
  • 1
  • 4

1 Answers1

2

Given a Binary instance bin, you can get the data as a bytes or bytearray instance by bin.data.

I can only guess from the code snippet you provided, but the following should work:

ret = pickle.loads(ret.data)
Manuel Jacob
  • 1,897
  • 10
  • 21