Mercurial > piecrust2
diff piecrust/data/iterators.py @ 455:cb3446be44b7
bake: Abort "render first" jobs if we start using other pages.
This prevents the baker from having one worker stuck on a very long job, like
rendering the index page of a blog with lots and lots of posts.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 08 Jul 2015 22:51:29 -0700 |
parents | fd8e39254da0 |
children | 911a054f4fbd |
line wrap: on
line diff
--- a/piecrust/data/iterators.py Mon Jul 06 21:32:40 2015 -0700 +++ b/piecrust/data/iterators.py Wed Jul 08 22:51:29 2015 -0700 @@ -1,6 +1,8 @@ import logging from piecrust.data.filters import PaginationFilter +from piecrust.environment import AbortedSourceUseError from piecrust.events import Event +from piecrust.sources.base import PageSource from piecrust.sources.interfaces import IPaginationSource @@ -289,6 +291,13 @@ if self._pagesData is not None: return + if (self._current_page is not None and + self._current_page.app.env.abort_source_use and + isinstance(self._source, PageSource)): + logger.debug("Aborting iteration from %s." % + self._current_page.ref_spec) + raise AbortedSourceUseError() + self._ensureSorter() it_chain = self._pages