Mercurial > piecrust2
comparison 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 |
comparison
equal
deleted
inserted
replaced
665:5dc13c816045 | 666:81d9c3a3a0b5 |
---|---|
538 logger.error("Errors found in %s:" % rel_path) | 538 logger.error("Errors found in %s:" % rel_path) |
539 for e in errors: | 539 for e in errors: |
540 logger.error(" " + e) | 540 logger.error(" " + e) |
541 | 541 |
542 def _createWorkerPool(self, previous_record_path): | 542 def _createWorkerPool(self, previous_record_path): |
543 from piecrust.app import PieCrustFactory | |
543 from piecrust.workerpool import WorkerPool | 544 from piecrust.workerpool import WorkerPool |
544 from piecrust.baking.worker import BakeWorkerContext, BakeWorker | 545 from piecrust.baking.worker import BakeWorkerContext, BakeWorker |
545 | 546 |
547 appfactory = PieCrustFactory( | |
548 self.app.root_dir, | |
549 cache=self.app.cache.enabled, | |
550 cache_key=self.app.cache_key, | |
551 config_variant=self.applied_config_variant, | |
552 config_values=self.applied_config_values, | |
553 debug=self.app.debug, | |
554 theme_site=self.app.theme_site) | |
555 | |
546 worker_count = self.app.config.get('baker/workers') | 556 worker_count = self.app.config.get('baker/workers') |
547 batch_size = self.app.config.get('baker/batch_size') | 557 batch_size = self.app.config.get('baker/batch_size') |
548 | 558 |
549 ctx = BakeWorkerContext( | 559 ctx = BakeWorkerContext( |
550 self.app.root_dir, self.app.cache.base_dir, self.out_dir, | 560 appfactory, |
551 previous_record_path=previous_record_path, | 561 self.out_dir, |
552 config_variant=self.applied_config_variant, | 562 force=self.force, |
553 config_values=self.applied_config_values, | 563 previous_record_path=previous_record_path) |
554 force=self.force, debug=self.app.debug, | |
555 theme_site=self.app.theme_site) | |
556 pool = WorkerPool( | 564 pool = WorkerPool( |
557 worker_count=worker_count, | 565 worker_count=worker_count, |
558 batch_size=batch_size, | 566 batch_size=batch_size, |
559 worker_class=BakeWorker, | 567 worker_class=BakeWorker, |
560 initargs=(ctx,)) | 568 initargs=(ctx,)) |