#-*- coding:utf-8 -*-
#threadpool是一个比较老的模块了,现在虽然还有一些人在用,但已经不再是主流了
import threadpool
import dict_down #调用:https://blog.youkuaiyun.com/meizhen51/article/details/79861796
task_pool = threadpool.ThreadPool(5)
#同时下载多个词典
def get_dict_more(keys=[]):
if len(keys) == 0:
return
req_list = threadpool.makeRequests(dict_down.get_dict,keys)
for req in req_list:
task_pool.putRequest(req)
print(req)
task_pool.wait()
if __name__ == '__main__':
get_dict_more(keys=['论语','曾子','子思子','孝经','孟子','荀子','老子','庄子','文子'])
多线程threadpool 执行多个requests请求
最新推荐文章于 2025-03-01 19:27:51 发布