我正在尝试并行化一个函数,该函数使用多处理库将结果附加到共享列表,并不断出现以下错误:
TypeError: '<=' not supported between instances of 'ListProxy' and 'Int'
我想让我困惑的部分是把每个结果附加到一个共享列表中。如果我去掉这部分代码,脚本就可以正常运行。然而,运行这个脚本的关键是将许多内容附加到一个列表中。你知道吗
一个google搜索告诉我这个错误是因为我在“比较一个序列和一个整数”。我知道错误在说什么,但我不知道如何用多处理库来解释它
我不确定我在这里做错了什么。有人能给我指一下正确的方向吗?你知道吗
下面是我尝试使用的代码的简化版本
import lasio
import glob
from multiprocessing import Pool, Process, Manager
#generates a list of filepaths to be fed to the parralelization
wellfiles = []
for file in glob.glob(....filedierctory...//*):
wellfiles.append(file)
def process_file(filepath,L):
#read the file
las = lasio.read(filepath)
#extract the value I want from the file
uwi = las.well[11].value
#print the value
print(uwi)
#append the value to a shared list. THIS IS WHERE I THINK THINGS ARE FAILING
L.append(uwi)
if __name__ == '__main__':
with Manager() as manager:
L = manager.list()
p = Pool(5)
p.map(process_file, wellfiles,L)
p.join()
如果我能澄清什么,请告诉我
目前没有回答
相关问题 更多 >
编程相关推荐