Mercurial > piecrust2
changeset 214:09e350db7f8f
serve: Don't have 2 processing loops running when using `--use-reloader`.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 31 Jan 2015 16:28:16 -0800 |
parents | e34a6826a3d4 |
children | a47580a0955b |
files | piecrust/serving.py |
diffstat | 1 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/serving.py Sat Jan 31 15:33:18 2015 -0800 +++ b/piecrust/serving.py Sat Jan 31 16:28:16 2015 -0800 @@ -72,9 +72,17 @@ self._out_dir = os.path.join(app.cache_dir, 'server') self._page_record = ServeRecord() - pipeline = ProcessorPipeline(app, self._out_dir) - loop = ProcessingLoop(pipeline) - loop.start() + if (not self.use_reloader or + os.environ.get('WERKZEUG_RUN_MAIN') == 'true'): + # We don't want to run the processing loop here if this isn't + # the actual process that does the serving. In most cases it is, + # but if we're using Werkzeug's reloader, then it won't be the + # first time we get there... it will only be the correct process + # the second time, when the reloading process is spawned, with the + # `WERKZEUG_RUN_MAIN` variable set. + pipeline = ProcessorPipeline(app, self._out_dir) + loop = ProcessingLoop(pipeline) + loop.start() # Run the WSGI app. wsgi_wrapper = WsgiServer(self)