diff piecrust/processing/worker.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/processing/worker.py	Thu Mar 03 08:19:28 2016 -0800
+++ b/piecrust/processing/worker.py	Thu Mar 03 08:22:41 2016 -0800
@@ -2,7 +2,7 @@
 import os.path
 import time
 import logging
-from piecrust.app import PieCrust
+from piecrust.app import PieCrust, apply_variant_and_values
 from piecrust.processing.base import PipelineContext
 from piecrust.processing.records import (
         FLAG_NONE, FLAG_PREPARED, FLAG_PROCESSED,
@@ -23,14 +23,12 @@
 
 
 class ProcessingWorkerContext(object):
-    def __init__(self, root_dir, out_dir, tmp_dir, *,
-                 force=False, debug=False, theme_site=False):
-        self.root_dir = root_dir
+    def __init__(self, appfactory, out_dir, tmp_dir, *,
+                 force=False):
+        self.appfactory = appfactory
         self.out_dir = out_dir
         self.tmp_dir = tmp_dir
         self.force = force
-        self.debug = debug
-        self.theme_site = theme_site
         self.is_profiling = False
         self.enabled_processors = None
         self.additional_processors = None
@@ -60,8 +58,7 @@
 
     def initialize(self):
         # Create the app local to this worker.
-        app = PieCrust(self.ctx.root_dir, debug=self.ctx.debug,
-                       theme_site=self.ctx.theme_site)
+        app = self.ctx.appfactory.create()
         app.env.registerTimer("PipelineWorker_%d_Total" % self.wid)
         app.env.registerTimer("PipelineWorkerInit")
         app.env.registerTimer("JobReceive")