downloader.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:LeoMuFundPicker 作者: leodengyx 项目源码 文件源码
def thread_func(downloader, thread_id, exporter):

    logger.debug("Starting thread %d" % thread_id)

    mutual_fund_id_count = len(downloader.mutual_fund_id_list)
    start_pos = mutual_fund_id_count/20 * thread_id
    end_pos = mutual_fund_id_count/20 * (thread_id+1)

    for i in range(start_pos, end_pos):
        if i >= len(downloader.mutual_fund_id_list):
            return

        mutual_fund_inst = downloader.save_mutual_fund_info(downloader.mutual_fund_id_list[i])
        if mutual_fund_inst is None:
            continue
        exporter.write_mutual_fund_to_file(mutual_fund_inst, thread_id, i-start_pos)

        downloader.lock.acquire()
        downloader.current_finish_count += 1
        sys.stdout.write("\rNow processing #%d Mutual Fund." % downloader.current_finish_count)
        sys.stdout.flush()
        downloader.lock.release()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号