irmen / Pyro5

Pyro 5 - Python remote objects
https://pyro5.readthedocs.io
MIT License
305 stars 36 forks source link

Suppress Serialization/ reflexive method call #40

Closed gkaissis closed 3 years ago

gkaissis commented 3 years ago

Is it possible to use the SerializedBlob (or some other construct) to suppress serialization on a certain return statement? We would like to send a plain bytestring which is efficiently pre-serialized in a custom format directly via return from an RPC to a daemon.

also: is there a simple way to perform a reflexive rpc call? Example:

#(Proxy side)
def do_something_onproxy():
    ...
    return b'proxy says hello'

server_msg=server.do_something()
print(server_msg)

>>server says hello

#(Server side)
def do_something_onserver():
    ...
    proxy_msg=proxy.do_something()
    return b'server says hello'

print(proxy_msg)
>>proxy says hello

I looked into the callback example but it left me a tad confused...

Thanks and congratulations for your great work on this project!

irmen commented 3 years ago

SerializedBlob is only for request arguments so you can't use it for responses. Maybe I'll look into this to see if this perhaps can be added in a future version.

In the meantime, the easiest solution is to just not worry about it and pass the bytes as a regular result. If you're not happy with the performance, consider switching to marshal as pyro serializer format, or try one of the other 'raw bytes' transfer options mentioned in the docs https://pyro5.readthedocs.io/en/latest/tipstricks.html#binary-data-transfer-file-transfer

Second question: what do you mean exactly with "reflexive rpc call"?

gkaissis commented 3 years ago

Thanks a lot for the clarification!

By reflexive, I mean a client call to the server which triggers a server call to the client. I suppose "callback" is the closest to what I am thinking, but the mental model of the "server" calling the "client" isn't entirely clear to me from the example. My concrete use-case is the following:

I hope this makes sense... Thanks again!

irmen commented 3 years ago

@gkaissis you closed the issue, managed to get the callbacks working?

gkaissis commented 3 years ago

I did, but then refactored the routine to be more Pyro-like with remote generators and a one-way call which made it both faster and more elegant. Thanks for your help!

irmen commented 3 years ago

I am glad you found a good solution !