我想跳过从map_async
. 它们在内存中增长,但我不需要它们。
这是一些代码:
def processLine(line):
#process something
print "result"
pool = Pool(processes = 8)
for line in sys.stdin:
lines.append(line)
if len(lines) >= 100000:
pool.map_async(processLine, lines, 2000)
pool.close()
pool.join()
当我必须处理具有数亿行的文件时,python 进程在内存中增长到几 GB。我该如何解决?
谢谢你的帮助 :)