Concurrent.futures代码以“BrokenProcessPool”结尾

时间:2017-07-05 10:20:19

标签: python multithreading concurrent.futures

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

 case R.id.eleaf:

                    if (checked) {
                        Toast.makeText(this, "E-Leaf Map shown", Toast.LENGTH_SHORT).show();
                    }
                    item.setChecked(!item.isChecked()); // this will make check,uncheck
                    break;

我得到的错误是:

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

有什么想法吗?

0 个答案:

没有答案