Вчера я задал аналогичный вопрос, и кто-то предложил мне использовать 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(loop, of, filename)
- person stovfl   schedule 06.07.2017