Python 3.x 如何使用rpyc将数据从服务器发送到客户端和从客户端发送到服务器?

Python 3.x 如何使用rpyc将数据从服务器发送到客户端和从客户端发送到服务器?,python-3.x,multithreading,multiprocessing,rpyc,Python 3.x,Multithreading,Multiprocessing,Rpyc,我想从服务器到客户端和客户端到服务器连续发送数据,但不幸的是,我没有得到所需的输出。有人能指出我哪里做错了吗 服务器端: import rpyc import threading class MyService(rpyc.Service): def on_connect(self, conn): print("connected to", conn.root.get_service_name()) self.exposed(conn

我想从服务器到客户端和客户端到服务器连续发送数据,但不幸的是,我没有得到所需的输出。有人能指出我哪里做错了吗

服务器端:

import rpyc
import threading

class MyService(rpyc.Service):

    def on_connect(self, conn):
        print("connected to", conn.root.get_service_name())
        self.exposed(conn)

    def on_disconnect(self, conn):
        pass

    def func1(self):
        #return "hello world"
        inp = input("")
        return inp

    def exposed(self, conn):
         while True:
            a = conn.root.func2()
            print(a)
         


if __name__ == "__main__":
    from rpyc.utils.server import ThreadedServer

    print("Server is ready")
    t = ThreadedServer(MyService, port=8008, protocol_config={'allow_all_attrs': True}).start()
#
客户端

import rpyc
import time

class ClientService(rpyc.SlaveService):
    def func2(self):
        #return "Hello World"
        inp = input("")
        return inp


if __name__ == "__main__":
    print("waiting for connection")
    conn = rpyc.connect("192.168.10.142", 8008, service=ClientService)
    print("connected to", conn.root.get_service_name())
    while True:
        a=conn.root.func1()
        print(a)