Mercurial > piecrust2
comparison piecrust/baking/baker.py @ 456:5e902e228053
bake: Correctly use the `num_worers` setting.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 09 Jul 2015 21:21:40 -0700 |
parents | 8351a77e13f5 |
children | 04abc97dd3b6 |
comparison
equal
deleted
inserted
replaced
455:cb3446be44b7 | 456:5e902e228053 |
---|---|
22 def __init__(self, app, out_dir, force=False): | 22 def __init__(self, app, out_dir, force=False): |
23 assert app and out_dir | 23 assert app and out_dir |
24 self.app = app | 24 self.app = app |
25 self.out_dir = out_dir | 25 self.out_dir = out_dir |
26 self.force = force | 26 self.force = force |
27 self.num_workers = app.config.get('baker/workers', | |
28 multiprocessing.cpu_count()) | |
29 | 27 |
30 # Remember what taxonomy pages we should skip | 28 # Remember what taxonomy pages we should skip |
31 # (we'll bake them repeatedly later with each taxonomy term) | 29 # (we'll bake them repeatedly later with each taxonomy term) |
32 self.taxonomy_pages = [] | 30 self.taxonomy_pages = [] |
33 logger.debug("Gathering taxonomy page paths:") | 31 logger.debug("Gathering taxonomy page paths:") |
540 | 538 |
541 def _createWorkerPool(self, previous_record_path): | 539 def _createWorkerPool(self, previous_record_path): |
542 from piecrust.workerpool import WorkerPool | 540 from piecrust.workerpool import WorkerPool |
543 from piecrust.baking.worker import BakeWorkerContext, BakeWorker | 541 from piecrust.baking.worker import BakeWorkerContext, BakeWorker |
544 | 542 |
543 worker_count = self.app.config.get('baker/workers') | |
544 | |
545 ctx = BakeWorkerContext( | 545 ctx = BakeWorkerContext( |
546 self.app.root_dir, self.app.cache.base_dir, self.out_dir, | 546 self.app.root_dir, self.app.cache.base_dir, self.out_dir, |
547 previous_record_path=previous_record_path, | 547 previous_record_path=previous_record_path, |
548 force=self.force, debug=self.app.debug) | 548 force=self.force, debug=self.app.debug) |
549 pool = WorkerPool( | 549 pool = WorkerPool( |
550 worker_count=worker_count, | |
550 worker_class=BakeWorker, | 551 worker_class=BakeWorker, |
551 initargs=(ctx,)) | 552 initargs=(ctx,)) |
552 return pool | 553 return pool |
553 | 554 |
554 | 555 |