客户端可以直接调用服务端代码。

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 "111"

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2021-09-17
  • 2021-07-22
  • 2022-02-14
  • 2022-12-23
猜你喜欢
  • 2021-08-10
  • 2021-06-16
  • 2021-07-09
  • 2021-12-12
  • 2021-11-09
  • 2022-01-26
  • 2022-01-06
相关资源
相似解决方案