4
我有一個PY文件下面的類定義:Pyro4有回調
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)
而且我在另一個文件這主要代碼:
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())
如果你運行這段代碼,你可以看到,它正在運行。現在我試圖用Pyro4運行相同的代碼。當我這樣做,我總是碰到下面的錯誤信息:
Pyro4.errors.SerializeError: unsupported serialized class: builtins.function
以下行:
q.bind_to_apple(print_on_change)
我的問題是: 這甚至可能與Pyro4或者這是一個限制序列化程序?如果我嘗試使用鹹菜而不是蛇,這可以解決嗎?
如果不是有Pyro4的替代品,你可以爲我建議這種情況下?
在此先感謝。
不要編輯configuration.py文件本身,因爲它是庫的一部分!使用另一種方式來更改配置項(例如通過使用適當的環境變量) –