comparison piecrust/sources/array.py @ 411:e7b865f8f335

bake: Enable multiprocess baking. Baking is now done by running a worker per CPU, and sending jobs to them. This changes several things across the codebase: * Ability to not cache things related to pages other than the 'main' page (i.e. the page at the bottom of the execution stack). * Decouple the baking process from the bake records, so only the main process keeps track (and modifies) the bake record. * Remove the need for 'batch page getters' and loading a page directly from the page factories. There are various smaller changes too included here, including support for scope performance timers that are saved with the bake record and can be printed out to the console. Yes I got carried away. For testing, the in-memory 'mock' file-system doesn't work anymore, since we're spawning processes, so this is replaced by a 'tmpfs' file-system which is saved in temporary files on disk and deleted after tests have run.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 12 Jun 2015 17:09:19 -0700
parents f130365568ff
children ab5c6a8ae90a
comparison
equal deleted inserted replaced
410:d1a472464e57 411:e7b865f8f335
1 from piecrust.sources.base import PageSource 1 from piecrust.sources.base import PageSource
2 from piecrust.sources.mixins import SimplePaginationSourceMixin 2 from piecrust.sources.mixins import SimplePaginationSourceMixin
3 from piecrust.sources.pageref import PageRef
3 4
4 5
5 class CachedPageFactory(object): 6 class CachedPageFactory(object):
6 """ A `PageFactory` (in appearance) that already has a page built. 7 """ A `PageFactory` (in appearance) that already has a page built.
7 """ 8 """
28 return self._page 29 return self._page
29 30
30 31
31 class ArraySource(PageSource, SimplePaginationSourceMixin): 32 class ArraySource(PageSource, SimplePaginationSourceMixin):
32 def __init__(self, app, inner_source, name='array', config=None): 33 def __init__(self, app, inner_source, name='array', config=None):
33 super(ArraySource, self).__init__(app, name, config or {}) 34 super(ArraySource, self).__init__(app, name, config)
34 self.inner_source = inner_source 35 self.inner_source = inner_source
35 36
36 @property 37 @property
37 def page_count(self): 38 def page_count(self):
38 return len(self.inner_source) 39 return len(self.inner_source)
39 40
40 def getPageFactories(self): 41 def getPageFactories(self):
41 for p in self.inner_source: 42 for p in self.inner_source:
42 yield CachedPageFactory(p) 43 yield CachedPageFactory(p)
43 44
45 def getTaxonomyPageRef(self, tax_name):
46 return None
47