【发布时间】:2019-02-12 18:30:35
【问题描述】:
我对 Python 多处理概念很陌生。
我正在尝试调用函数magicFunction,它有多个参数,其中第一个是可迭代的,而其他所有参数都是不可迭代的。另外,它返回多个值,比如x, y, z
我想弄清楚如何在这里使用executor。这是我的方法,这显然是错误的。
def magicFunction(webElem, uid_list, ignoreTagsList):
..
..
return x,y,z
with concurrent.futures.ProcessPoolExecutor() as executor:
for webElem, x_val, y_val, z_val in zip(webElem_list, executor.map(magicFunction, webElem_list, uid_list, ignoreTagsList)):
..
..
print("Values:", x_val, y_val, z_val)
有人可以建议正确的方法吗?
【问题讨论】:
标签: python-3.x python-multiprocessing threadpoolexecutor