python处理多并发模块:socketserver
[例]:
server端:
socetserver下的ThreadingTCPServer()方法是处理多个连接,写法按照下面的方式。
1 import socketserver 2 class MyHandler(socketserver.BaseRequestHandler) 3 4 def handler(): 5 pass 6 7 if __name__=='__main__': 8 host,port='127.0.0.1',9999 9 server=socketserver.ThreadingTCPServer((host,port),MyHandler) 10 server.serve_forever()