Serializing and sending Function to remote machine
Closed this issue · 2 comments
Dear Mike,
It's me from stack overflow, you asked me to create a ticket here on github. I'm not sure if this that I am trying is "supposed" to work, but anyway, here's a more substantial description of my problem.
You speculated that my different machines could be running different python version. While this is valid conjecture, I tested to print the python version on both the client and server side when the code was run, and both are using python3.8. This is unsurprising as they actually use a virtual environment that is shared as a NFS, so basically the same data.
On the local machine (in my app, the 'GUI-side'):
class Client():
def SendFunction(self):
serializedFunction = dill.dumps(self.TestFunction.__func__)
self.RemoteServer.ExecuteFunction(serializedFunction)
def TestFunction(self):
print(666)
On the remote side (Which is a Pyro5 proxy object registered at a Pyro5 nameserver and running on a separate machine):
class RemoteServer():
def ExecuteFunction(self, serializedFunction):
func = dill.loads(serpent.tobytes(serializedFunction))
# This is Pyro5 procedure, manually translating the serialized dictionary to bytes, enabling re-serialization with dill... Supposedly. I tested this step by sending the serialized function back to the client (just using return on the remote server), and this successfully allowed me to re-serialize the function using the same line as above, only on the client side.
So, embarrassingly enough I found that this was actually indeed a python versioning issue. I can't explain how python3.9 snuck in there, but it did. Like I said, I checked the python version, and both the server and client reported that they were using 3.8, even from within the serialization and de-serialization python functions they reported this! I installed new virtual environments and updated python to 3.9, and it worked. Thanks for taking my query seriously anyway!
@JonesBareBones: No worries. I'm glad you figured it out. (ref: https://stackoverflow.com/questions/73675366)