Mercurial > piecrust2
comparison piecrust/sources/mixins.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 | 4b1019bb2533 |
children | 32c7c2d219d2 |
comparison
equal
deleted
inserted
replaced
410:d1a472464e57 | 411:e7b865f8f335 |
---|---|
3 import logging | 3 import logging |
4 from piecrust.data.base import PaginationData | 4 from piecrust.data.base import PaginationData |
5 from piecrust.data.filters import PaginationFilter, page_value_accessor | 5 from piecrust.data.filters import PaginationFilter, page_value_accessor |
6 from piecrust.sources.base import PageFactory | 6 from piecrust.sources.base import PageFactory |
7 from piecrust.sources.interfaces import IPaginationSource, IListableSource | 7 from piecrust.sources.interfaces import IPaginationSource, IListableSource |
8 from piecrust.sources.pageref import PageNotFoundError | 8 from piecrust.sources.pageref import PageRef |
9 | 9 |
10 | 10 |
11 logger = logging.getLogger(__name__) | 11 logger = logging.getLogger(__name__) |
12 | 12 |
13 | 13 |
39 | 39 |
40 def _cacheTaxonomyPages(self): | 40 def _cacheTaxonomyPages(self): |
41 if self._taxonomy_pages is not None: | 41 if self._taxonomy_pages is not None: |
42 return | 42 return |
43 | 43 |
44 app = self.source.app | |
44 self._taxonomy_pages = set() | 45 self._taxonomy_pages = set() |
45 for tax in self.source.app.taxonomies: | 46 for src in app.sources: |
46 page_ref = tax.getPageRef(self.source.name) | 47 for tax in app.taxonomies: |
47 try: | 48 ref_spec = src.getTaxonomyPageRef(tax.name) |
48 self._taxonomy_pages.add(page_ref.rel_path) | 49 page_ref = PageRef(app, ref_spec) |
49 except PageNotFoundError: | 50 for sn, rp in page_ref.possible_split_ref_specs: |
50 pass | 51 if sn == self.source.name: |
52 self._taxonomy_pages.add(rp) | |
51 | 53 |
52 | 54 |
53 class DateSortIterator(object): | 55 class DateSortIterator(object): |
54 def __init__(self, it, reverse=True): | 56 def __init__(self, it, reverse=True): |
55 self.it = it | 57 self.it = it |