from multiprocessing.dummy import Pool
executor = Pool(10) # 构造线程池
executor.map()
executor.apply_async()
from concurrent.futures import ThreadPoolExecutor
threadPool = ThreadPoolExecutor(max_workers=10)
threadPool.submit()
from multiprocessing.pool import Pool
executor = Pool(200) # 构造进程池
executor.apply_async()
from concurrent.futures import ProcessPoolExecutor
with ProcessPoolExecutor(max_workers=5) as pool:
pool.map()
进程池技术创建任务列表
def all_precept(self): # 获取所有方案 返回值[接口1,……,接口n]
result = Publie().read_hive_planid(rq)
port_list = []
pool = Pool(200)
res = []
for program_list in result:
res.append(pool.apply_async(self.load_plan, args=(program_list,)))
pool.close()
pool.join()
for i in res:
i.wait()
for r in res:
port_list.append(r.get())