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()
评论列表
文章目录