diff piecrust/baking/baker.py @ 666:81d9c3a3a0b5

internal: Get rid of the whole "sub cache" business. * Compute cache keys up front, so the cache directory is only chosen once. * Buffer up config variants to apply before loading the config. Makes it possible to cache variant-resulting configs, too. * Make a factory class to reuse the logic that creates the `PieCrust` object correctly for multi-process workers and such. * Add a test.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 03 Mar 2016 08:22:41 -0800
parents 3ceeca7bb71c
children 61d606fbc313
line wrap: on
line diff
--- a/piecrust/baking/baker.py	Thu Mar 03 08:19:28 2016 -0800
+++ b/piecrust/baking/baker.py	Thu Mar 03 08:22:41 2016 -0800
@@ -540,19 +540,27 @@
             logger.error("  " + e)
 
     def _createWorkerPool(self, previous_record_path):
+        from piecrust.app import PieCrustFactory
         from piecrust.workerpool import WorkerPool
         from piecrust.baking.worker import BakeWorkerContext, BakeWorker
 
+        appfactory = PieCrustFactory(
+                self.app.root_dir,
+                cache=self.app.cache.enabled,
+                cache_key=self.app.cache_key,
+                config_variant=self.applied_config_variant,
+                config_values=self.applied_config_values,
+                debug=self.app.debug,
+                theme_site=self.app.theme_site)
+
         worker_count = self.app.config.get('baker/workers')
         batch_size = self.app.config.get('baker/batch_size')
 
         ctx = BakeWorkerContext(
-                self.app.root_dir, self.app.cache.base_dir, self.out_dir,
-                previous_record_path=previous_record_path,
-                config_variant=self.applied_config_variant,
-                config_values=self.applied_config_values,
-                force=self.force, debug=self.app.debug,
-                theme_site=self.app.theme_site)
+                appfactory,
+                self.out_dir,
+                force=self.force,
+                previous_record_path=previous_record_path)
         pool = WorkerPool(
                 worker_count=worker_count,
                 batch_size=batch_size,