并行网络请求:比较不同的方法

问题描述 投票:-4回答:1

我想一次请求100个网址,目前正在这样做:

responses = list(PoolExecutor(max_workers=NUM_PARALLEL).map(
                 lambda xml: requests.post(URL, headers=HEADERS, data={'message': xml}), 
                 xmls))

有关此问题:

  1. list是“评估”实际生成器对象/表达式的最佳方法吗?除非我执行list,否则我只会得到类似以下内容的内容:<generator object Executor.map.<locals>.result_iterator at 0x10ecf9888>
  2. PoolExecutor是否经常用于python3中的并行网络请求,还是有其他更可取的方法?
  3. PoolExecutorAsyncIOconcurrent.futures之间的区别是什么?
python python-3.x concurrency pool
1个回答
0
投票
是列出“评估”实际生成器的最佳方法对象/表达式?除非我列出来,否则我只会得到类似以下内容的信息:.result_iterator位于0x10ecf9888>
© www.soinside.com 2019 - 2024. All rights reserved.