Open kemistep opened 4 years ago
这里是多线程精华
with ThreadPoolExecutor(max_workers=3) as executor: # 线程
#with ProcessPoolExecutor(max_workers=3) as executor: # 进程
future_to_url = {executor.submit(get_xueqiu_quote_stock_daily,stock_code): stock_code for stock_code in stock_code_list}
for future in concurrent.futures.as_completed(future_to_url):
location = future_to_url[future]
try:
info = future.result()
result_list.append(info)
except Exception as exc:
print('%r generated an exception: %s' % (location, exc))
times = time.time() - begin_time
print(times)