多线程编程在Python中怎么实现?
提问人:杨紫红发布时间:2020-11-17
import thread
from SimpleXMLRPCServer import SimpleXMLRPCServer
from xmlrpclib import ServerProxy
def msg(s):
print s
return True
def run_server():
my_server = SimpleXMLRPCServer( ("localhost", 8001) )
my_server.register_function(msg)
my_server.serve_forever()
def run_client():
your_server = ServerProxy("http://localhost:8002")
while True:
msg = raw_input()
your_server.msg(msg)
thread.start_new_thread( run_server, () )
run_client()
继续查找其他问题的答案?
相关视频回答
回复(0)
点击加载更多评论>>