import socketserverclass MyServer(socketserver.BaseRequestHandler): def handle(self): #继承BaseRequestHandler后就要重写handle方法 print(self.request) #相当于coon print(self.client_address) #相当于addr while True: try: #收消息 data = self.request.recv(1024) if not data…
python高级之多进程 本节内容 多进程概念 Process类 进程间通讯 进程同步 进程池 1.多进程概念 multiprocessing is a package that supports spawning processes using an API similar to the threading module. The multiprocessing package offers both local and remote concurrency,effectively side-…
1.多线程:开启一个进程test.py ,占用两个cpu 共占用45%左右(top -c ,按1) 多进程:开启两个进程test.py 用两个cpu 90%*2左右 test.py # coding=utf-8 from multiprocessing import Pool # 多线程版本from multiprocessing.dummy import Pool import sys, os import time def timetask(times): while 1: pass…