diff piecrust/data/linker.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 fd8e39254da0
children 32c7c2d219d2
line wrap: on
line diff
--- a/piecrust/data/linker.py	Sat May 30 15:41:52 2015 -0700
+++ b/piecrust/data/linker.py	Fri Jun 12 17:09:19 2015 -0700
@@ -293,36 +293,35 @@
 
         items = list(self._source.listPath(self._dir_path))
         self._items = collections.OrderedDict()
-        with self._source.app.env.page_repository.startBatchGet():
-            for is_dir, name, data in items:
-                # If `is_dir` is true, `data` will be the directory's source
-                # path. If not, it will be a page factory.
-                if is_dir:
-                    item = Linker(self._source, data,
-                                  root_page_path=self._root_page_path)
-                else:
-                    page = data.buildPage()
-                    is_self = (page.rel_path == self._root_page_path)
-                    item = _LinkedPage(page)
-                    item._linker_info.name = name
-                    item._linker_info.is_self = is_self
-                    if is_self:
-                        self._self_item = item
+        for is_dir, name, data in items:
+            # If `is_dir` is true, `data` will be the directory's source
+            # path. If not, it will be a page factory.
+            if is_dir:
+                item = Linker(self._source, data,
+                              root_page_path=self._root_page_path)
+            else:
+                page = data.buildPage()
+                is_self = (page.rel_path == self._root_page_path)
+                item = _LinkedPage(page)
+                item._linker_info.name = name
+                item._linker_info.is_self = is_self
+                if is_self:
+                    self._self_item = item
 
-                existing = self._items.get(name)
-                if existing is None:
-                    self._items[name] = item
-                elif is_dir:
-                    # The current item is a directory. The existing item
-                    # should be a page.
-                    existing._linker_info.child_linker = item
-                    existing._linker_info.is_dir = True
-                else:
-                    # The current item is a page. The existing item should
-                    # be a directory.
-                    item._linker_info.child_linker = existing
-                    item._linker_info.is_dir = True
-                    self._items[name] = item
+            existing = self._items.get(name)
+            if existing is None:
+                self._items[name] = item
+            elif is_dir:
+                # The current item is a directory. The existing item
+                # should be a page.
+                existing._linker_info.child_linker = item
+                existing._linker_info.is_dir = True
+            else:
+                # The current item is a page. The existing item should
+                # be a directory.
+                item._linker_info.child_linker = existing
+                item._linker_info.is_dir = True
+                self._items[name] = item
 
 
 def filter_page_items(item):