Concurrent.futures code ends up with “BrokenProcessPool”

Viewed 591

Yesterday I asked a similar question and somebody suggested me to use concurrent.futures and asyncio. What I want is skipping the file if it takes too long to process. Here is my code:

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

And the error that I get is:

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

Any ideas ?

0 Answers
Related