Pyro4 with callbacks

I have the following class definition in a py file:

class this_obj(object):

    def __init__(self):
         self._apple = 5.0
         self.observ_apple = []

    def setter(self, value):
        if (self._apple != value):
            self._apple = value
            for callback in self.observ_apple:
                callback(self._apple)

    def getter(self):
        return self._apple

    # apply property
    apple = property(getter, setter)

    # binder functions
    def bind_to_apple(self, callback):
        self.observ_apple.append(callback)

And I have this main code in another file:

import handler_obj

def print_on_change(value):
    print("apple change!!! " + str(value))

if __name__ == "__main__":
    q = handler_obj.this_obj()
    q.bind_to_apple(print_on_change)
    print(q.getter())
    q.setter(30)
    print(q.getter())

If you run this code, you will see that it is running. Now I am trying to run the same code with Pyro4. Since I was doing this, I always came across the following error message:

Pyro4.errors.SerializeError: unsupported serialized class: builtins.function

for the next line:

q.bind_to_apple(print_on_change)

My question is: Is this possible with Pyro4 or is this a serializer limitation? Can this be solved if I try to use a pickle instead of a snake?

If not, is there an alternative to Pyro4 that you can offer me for such cases?

Thanks in advance.

+4
source share
1 answer

. config.py, , .

+1

All Articles