多线程threadpool 执行多个requests请求

#-*- coding:utf-8 -*-

#threadpool是一个比较老的模块了,现在虽然还有一些人在用,但已经不再是主流了
import threadpool
import dict_down #调用:https://blog.csdn.net/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=['论语','曾子','子思子','孝经','孟子','荀子','老子','庄子','文子'])

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值