客户端可以直接调用服务端代码。
rpycserver
#!/usr/bin/env python
#coding:utf-8 from rpyc.core.service import SlaveService
from rpyc.utils.server import ThreadedServer #----------------------------------------------------------------------
class hhh():
""""""
@staticmethod
def test():
return "test" if __name__ == '__main__': server =ThreadedServer(SlaveService, hostname="127.0.0.1", ipv6=False, port=2222,
backlog=10,
reuse_addr=True,
authenticator=None,
registrar=None,
auto_register=None,
protocol_config={},
logger=None,
listener_timeout=0.5)
server.start()
rpycClient
#!/usr/bin/env python
#coding:utf-8 import rpyc if __name__ == '__main__': conn = rpyc.classic.connect("localhost", port=2222, ipv6=False,
keepalive=False)
result=conn.modules['testRpyc'].hhh.test()
print result print ""