Mercurial > piecrust2
comparison piecrust/serving.py @ 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 | 7a5a7a7e8cee |
children | d7a548ebcd58 |
comparison
equal
deleted
inserted
replaced
213:e34a6826a3d4 | 214:09e350db7f8f |
---|---|
70 # them to the client. We need a temp app for this. | 70 # them to the client. We need a temp app for this. |
71 app = PieCrust(root_dir=self.root_dir, debug=self.debug) | 71 app = PieCrust(root_dir=self.root_dir, debug=self.debug) |
72 self._out_dir = os.path.join(app.cache_dir, 'server') | 72 self._out_dir = os.path.join(app.cache_dir, 'server') |
73 self._page_record = ServeRecord() | 73 self._page_record = ServeRecord() |
74 | 74 |
75 pipeline = ProcessorPipeline(app, self._out_dir) | 75 if (not self.use_reloader or |
76 loop = ProcessingLoop(pipeline) | 76 os.environ.get('WERKZEUG_RUN_MAIN') == 'true'): |
77 loop.start() | 77 # We don't want to run the processing loop here if this isn't |
78 # the actual process that does the serving. In most cases it is, | |
79 # but if we're using Werkzeug's reloader, then it won't be the | |
80 # first time we get there... it will only be the correct process | |
81 # the second time, when the reloading process is spawned, with the | |
82 # `WERKZEUG_RUN_MAIN` variable set. | |
83 pipeline = ProcessorPipeline(app, self._out_dir) | |
84 loop = ProcessingLoop(pipeline) | |
85 loop.start() | |
78 | 86 |
79 # Run the WSGI app. | 87 # Run the WSGI app. |
80 wsgi_wrapper = WsgiServer(self) | 88 wsgi_wrapper = WsgiServer(self) |
81 run_simple(self.host, self.port, wsgi_wrapper, | 89 run_simple(self.host, self.port, wsgi_wrapper, |
82 use_debugger=self.debug, use_reloader=self.use_reloader) | 90 use_debugger=self.debug, use_reloader=self.use_reloader) |