使用os.scandir()来抓取一个非常大的目录,并将文件发送到已发现的多处理队列

时间:2018-05-19 23:10:51

标签: python-3.x python-multiprocessing python-multithreading

我有一个非常大的目录,想要递归,将文件发送到发现并行处理的多处理队列。

PATH = "/mnt/large_directory"

def main():

#Initialize
print("Starting the scanner in root " + PATH)

with os.scandir(PATH) as it:
  for entry in it:
      if not entry.name.startswith('.') and entry.is_file():
          print(entry.name)
          print(entry.path)

我有一个函数需要用来对每个文件执行工作:

def doWork()
//Calculates md5 sum and other check sums

这样做的正确方法是什么,以便在工作线程可用时将文件添加到多处理队列中?

0 个答案:

没有答案