服务器部分 - 核心,负责模块的注册和它们之间的交互。 Core作为ThreadedServer运行。 CoreService提供注册模块。注册时,我会保留一个Connections列表,然后使用它们。模块调用核心函数,它应该调用另一个模块。但是要使用连接列表不起作用,性能会进入无限循环。
class CoreService(rpyc.Service):
__modules = {}
def exposed_register_module(self, module_name):
if module_name in self.__modules:
return False
self.__modules[module_name] = self._conn
return True
def exposed_execute_query_module(self, module_name, attribute_name, args):
# TTTTTTTTTTHHHHHHHHHIIIIIIIISSSSSSSSSSSSSS
if module_name in self.__modules:
self.__modules[module_name].root
# return None
当你运行测试时,我进入一个被组合键中断的循环,并得到以下输出:
^CTraceback (most recent call last): File "/home/kpv/perseus/control-lib/perseus_control_lib/module.py", line 67, in __getattr__ return self.__core_connector.root.execute_query_module(self.__proxy_module_name, name, args) File "/usr/local/lib/python2.7/dist-packages/rpyc/core/netref.py", line 196, in __call__ return syncreq(_self, consts.HANDLE_CALL, args, kwargs) File "/usr/local/lib/python2.7/dist-packages/rpyc/core/netref.py", line 71, in syncreq return conn.sync_request(handler, oid, *args) File "/usr/local/lib/python2.7/dist-packages/rpyc/core/protocol.py", line 438, in sync_request self.serve(0.1) File "/usr/local/lib/python2.7/dist-packages/rpyc/core/protocol.py", line 387, in serve data = self._recv(timeout, wait_for_lock = True) File "/usr/local/lib/python2.7/dist-packages/rpyc/core/protocol.py", line 344, in _recv if self._channel.poll(timeout): File "/usr/local/lib/python2.7/dist-packages/rpyc/core/channel.py", line 43, in poll return self.stream.poll(timeout) File "/usr/local/lib/python2.7/dist-packages/rpyc/core/stream.py", line 41, in poll rl, _, _ = select([self], [], [], timeout) KeyboardInterrupt