comparison piecrust/processing/less.py @ 414:c4b3a7fd2f87

bake: Make pipeline processing multi-process. Not many changes here, as it's pretty straightforward, but an API change for processors so they know if they're being initialized/disposed from the main process or from one of the workers. This makes it possible to do global stuff that has side-effects (e.g. create a directory) vs. doing in-memory stuff.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 20 Jun 2015 19:20:30 -0700
parents c1d4e86a3918
children 35d4c172e5a6
comparison
equal deleted inserted replaced
413:eacf0a3afd0c 414:c4b3a7fd2f87
22 self._conf = None 22 self._conf = None
23 self._map_dir = None 23 self._map_dir = None
24 24
25 def onPipelineStart(self, pipeline): 25 def onPipelineStart(self, pipeline):
26 self._map_dir = os.path.join(pipeline.tmp_dir, 'less') 26 self._map_dir = os.path.join(pipeline.tmp_dir, 'less')
27 if not os.path.isdir(self._map_dir): 27 if (pipeline.is_first_worker and
28 not os.path.isdir(self._map_dir)):
28 os.makedirs(self._map_dir) 29 os.makedirs(self._map_dir)
29 30
30 def getDependencies(self, path): 31 def getDependencies(self, path):
31 map_path = self._getMapPath(path) 32 map_path = self._getMapPath(path)
32 try: 33 try:
40 return FORCE_BUILD 41 return FORCE_BUILD
41 42
42 # Get the sources, but make all paths absolute. 43 # Get the sources, but make all paths absolute.
43 sources = dep_map.get('sources') 44 sources = dep_map.get('sources')
44 path_dir = os.path.dirname(path) 45 path_dir = os.path.dirname(path)
46
45 def _makeAbs(p): 47 def _makeAbs(p):
46 return os.path.join(path_dir, p) 48 return os.path.join(path_dir, p)
47 deps = list(map(_makeAbs, sources)) 49 deps = list(map(_makeAbs, sources))
48 return [map_path] + deps 50 return [map_path] + deps
49 except IOError: 51 except IOError: