我有这段代码:
def characterize_file(filename):
try:
# …
return (filename, characterization)
except Exception as e:
print(filename)
traceback.print_exc()
raise e
def write_characterization(args):
# …
p = multiprocessing.Pool(3)
characterizations = p.imap(characterize_file, args)
for (i, (filename, characterization)) in enumerate(characterizations):
pass # …
有时,我得到这个例外,没有任何其他输出:
File "/home/progval/etudes/ens/image/dm/venv/local/lib/python2.7/site-packages/mogulex/main.py", line 52, in write_characterization
for (i, (filename, characterization)) in enumerate(characterizations):
File "/usr/lib/python2.7/multiprocessing/pool.py", line 659, in next
raise value
ValueError: need more than 1 value to unpack
它可能来自哪里? try语句不应该捕获任何错误并打印出来吗?