1.多线程线程池
threadpool 安装
pip install threadpool
from twisted.python.threadpool import ThreadPool
import threadpool
pool = ThreadPool(poolsize) # poolsize 线程大小
requests = threadpool.makeRequests(some_callable, list_of_args, callback)
# some_callable 多线程调用的方法
# list_of_args 列表数据参数
# callback 回调函数,一般不用,可忽略
[pool.putRequest(req) for req in requests]
pool.wait()
# 等待所有线程完成工作后推出
网友评论