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): ...@@ -22,9 +22,6 @@ class Compiler(object):
return [to_class(compiler) for compiler in settings.PIPELINE_COMPILERS] return [to_class(compiler) for compiler in settings.PIPELINE_COMPILERS]
def compile(self, paths, force=False): def compile(self, paths, force=False):
import multiprocessing
from concurrent import futures
def _compile(input_path): def _compile(input_path):
for compiler in self.compilers: for compiler in self.compilers:
compiler = compiler(verbose=self.verbose, storage=self.storage) compiler = compiler(verbose=self.verbose, storage=self.storage)
...@@ -42,6 +39,12 @@ class Compiler(object): ...@@ -42,6 +39,12 @@ class Compiler(object):
else: else:
return input_path return input_path
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: with futures.ThreadPoolExecutor(max_workers=multiprocessing.cpu_count()) as executor:
return list(executor.map(_compile, paths)) return list(executor.map(_compile, paths))
......
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