【发布时间】:2021-10-19 05:16:37
【问题描述】:
from itertools import product
from multiprocessing import Pool
with Pool(4) as pool:
pool.map(lambda x: run_test_function(x, arg2, arg3, arg4), arg1)
执行上述代码后出现以下错误。还有一些其他的代码,我不能在这里写。但实际问题仅来自这段代码。
Traceback (most recent call last):
File "modProfileChange_test.py", line 347, in <module>
main(sys.argv[1:])
File "modProfileChange_test.py", line 336, in main
test_run_code(arg1, arg2, arg3, arg4, arg5, arg6)
File "modProfileChange_test.py", line 23, in test_run_code
with Pool(4) as pool:
AttributeError: __exit__
【问题讨论】:
-
这已经是语法上有效的 Python 2.7 代码
-
那么使用的库呢?我只在另一个问题上关注您的代码。所以我对这个库不太熟悉。
-
没什么特别的,我猜?这是有效的 Python 2.7 代码
-
它的抛出错误。
-
您发布的代码只有 5 行。请发布minimal reproducible example 和full 错误消息(应以“Traceback”一词开头)。
标签: python-2.7 multiprocessing