Commit 9a391107 by Rajiv Bose Committed by Timothée Peignier

compilation failover

If multiprocessing and concurrent unspported, render linear compilation.
parent e9c392dd
......@@ -22,9 +22,6 @@ class Compiler(object):
return [to_class(compiler) for compiler in settings.PIPELINE_COMPILERS]
def compile(self, paths, force=False):
import multiprocessing
from concurrent import futures
def _compile(input_path):
for compiler in self.compilers:
compiler = compiler(verbose=self.verbose, storage=self.storage)
......@@ -42,8 +39,14 @@ class Compiler(object):
else:
return input_path
with futures.ThreadPoolExecutor(max_workers=multiprocessing.cpu_count()) as executor:
return list(executor.map(_compile, paths))
try:
import multiprocessing
from concurrent import futures
except ImportError:
return list(map(_compile, paths))
else:
with futures.ThreadPoolExecutor(max_workers=multiprocessing.cpu_count()) as executor:
return list(executor.map(_compile, paths))
def output_path(self, path, extension):
path = os.path.splitext(path)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment