Python Concurrent.futures代码以“结尾;经纪流程池”;

Python Concurrent.futures代码以“结尾;经纪流程池”;,python,multithreading,concurrent.futures,Python,Multithreading,Concurrent.futures,昨天我问了一个类似的问题,有人建议我使用concurrent.futures和asyncio。如果文件处理时间过长,我希望跳过该文件。这是我的密码: import os, glob import time import asyncio from concurrent.futures import ProcessPoolExecutor @asyncio.coroutine def coro(loop, of, filename): ex = ProcessPoolExecutor(4)

昨天我问了一个类似的问题,有人建议我使用concurrent.futures和asyncio。如果文件处理时间过长,我希望跳过该文件。这是我的密码:

import os, glob
import time
import asyncio
from concurrent.futures import ProcessPoolExecutor
@asyncio.coroutine
def coro(loop, of, filename):
    ex = ProcessPoolExecutor(4)
    yield from loop.run_in_executor(ex, os.system, "\"C:\\P.exe\" -o {} {}".format(of, filename))

for folder, subfolders, filenames in os.walk(directory):
         if any([filename.endswith('.scad') for filename in filenames]):
             if filename.endswith('.scad'):
                 os.chdir(folder)
                 of = filename.replace('.scad', '.stl') # name of the outfile .stl
                 try:
                    loop.run_until_complete(asyncio.wait_for(coro(loop, of, filename), 90))
                 except asyncio.TimeoutError:
                    print("Timed out file: {}".format(filename))
                    pass
我得到的错误是:

raise self._exception
concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.

有什么想法吗?

我想你必须使用完整的路径名,而不仅仅是文件名。是的,我只是在示例中这样写的。再次查看示例,你只传递文件名
coro(循环,of,Filename)