Mercurial > piecrust2
comparison piecrust/serving/procloop.py @ 1037:89d94955b818
serve: Fix infinite loop in asset processing when a change is detected.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 16 Jan 2018 08:41:25 -0800 |
parents | 7f1da7e7b154 |
children | 54eb8ad9e809 |
comparison
equal
deleted
inserted
replaced
1036:12a1bd7af52e | 1037:89d94955b818 |
---|---|
6 import logging | 6 import logging |
7 import itertools | 7 import itertools |
8 import threading | 8 import threading |
9 from piecrust import CONFIG_PATH, THEME_CONFIG_PATH | 9 from piecrust import CONFIG_PATH, THEME_CONFIG_PATH |
10 from piecrust.chefutil import format_timed_scope | 10 from piecrust.chefutil import format_timed_scope |
11 from piecrust.pipelines.base import ( | 11 from piecrust.pipelines.records import MultiRecord |
12 PipelineJobCreateContext, PipelineJobRunContext, PipelineJobResult, | |
13 PipelineManager) | |
14 from piecrust.pipelines.records import ( | |
15 MultiRecord, MultiRecordHistory) | |
16 | 12 |
17 | 13 |
18 logger = logging.getLogger(__name__) | 14 logger = logging.getLogger(__name__) |
19 | 15 |
20 # This flag is for cancelling all long running requests like SSEs. | 16 # This flag is for cancelling all long running requests like SSEs. |
150 if os.path.getmtime(path) > procinfo.last_bake_time: | 146 if os.path.getmtime(path) > procinfo.last_bake_time: |
151 logger.debug("Found modified asset: %s" % path) | 147 logger.debug("Found modified asset: %s" % path) |
152 found_new_or_modified = True | 148 found_new_or_modified = True |
153 break | 149 break |
154 if found_new_or_modified: | 150 if found_new_or_modified: |
155 with format_timed_scope( | 151 logger.info("change detected, reprocessed '%s'." % |
156 logger, | 152 procinfo.source.name) |
157 "change detected, reprocessed '%s'." % | 153 self._runPipelinesSafe(procinfo.source) |
158 procinfo.source.name): | 154 procinfo.last_bake_time = time.time() |
159 self._runPipelinesSafe(procinfo.source) | |
160 | 155 |
161 time.sleep(self.interval) | 156 time.sleep(self.interval) |
162 | 157 |
163 def _init(self): | 158 def _init(self): |
164 self._app = self.appfactory.create() | 159 self._app = self.appfactory.create() |