多線程編程在Python中怎么實(shí)現(xiàn)?
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()
點(diǎn)擊加載更多評(píng)論>>