Mercurial > piecrust2
comparison 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 |
comparison
equal
deleted
inserted
replaced
454:96d363e2da4b | 455:cb3446be44b7 |
---|---|
1 import logging | 1 import logging |
2 from piecrust.data.filters import PaginationFilter | 2 from piecrust.data.filters import PaginationFilter |
3 from piecrust.environment import AbortedSourceUseError | |
3 from piecrust.events import Event | 4 from piecrust.events import Event |
5 from piecrust.sources.base import PageSource | |
4 from piecrust.sources.interfaces import IPaginationSource | 6 from piecrust.sources.interfaces import IPaginationSource |
5 | 7 |
6 | 8 |
7 logger = logging.getLogger(__name__) | 9 logger = logging.getLogger(__name__) |
8 | 10 |
287 | 289 |
288 def _load(self): | 290 def _load(self): |
289 if self._pagesData is not None: | 291 if self._pagesData is not None: |
290 return | 292 return |
291 | 293 |
294 if (self._current_page is not None and | |
295 self._current_page.app.env.abort_source_use and | |
296 isinstance(self._source, PageSource)): | |
297 logger.debug("Aborting iteration from %s." % | |
298 self._current_page.ref_spec) | |
299 raise AbortedSourceUseError() | |
300 | |
292 self._ensureSorter() | 301 self._ensureSorter() |
293 | 302 |
294 it_chain = self._pages | 303 it_chain = self._pages |
295 is_pgn_source = False | 304 is_pgn_source = False |
296 if isinstance(self._source, IPaginationSource): | 305 if isinstance(self._source, IPaginationSource): |