lazy load app on reload only

This commit is contained in:
David Lord 2019-11-18 12:36:00 -08:00
parent a83d6d2528
commit 240a11052b
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
2 changed files with 8 additions and 4 deletions

View file

@ -10,6 +10,9 @@ Unreleased
- Add :meth:`Config.from_file` to load config using arbitrary file
loaders, such as ``toml.load`` or ``json.load``.
:meth:`Config.from_json` is deprecated in favor of this. :pr:`3398`
- The ``flask run`` command will only defer errors on reload. Errors
present during the initial call will cause the server to exit with
the traceback immediately. :issue:`3431`
Version 1.1.2

View file

@ -296,11 +296,15 @@ class DispatchingApp(object):
of the Werkzeug debugger means that it shows up in the browser.
"""
def __init__(self, loader, use_eager_loading=False):
def __init__(self, loader, use_eager_loading=None):
self.loader = loader
self._app = None
self._lock = Lock()
self._bg_loading_exc_info = None
if use_eager_loading is None:
use_eager_loading = os.environ.get("WERKZEUG_RUN_MAIN") != "true"
if use_eager_loading:
self._load_unlocked()
else:
@ -841,9 +845,6 @@ def run_command(
if debugger is None:
debugger = debug
if eager_loading is None:
eager_loading = not reload
show_server_banner(get_env(), debug, info.app_import_path, eager_loading)
app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)