lazy load app on reload only
This commit is contained in:
parent
a83d6d2528
commit
240a11052b
2 changed files with 8 additions and 4 deletions
|
|
@ -10,6 +10,9 @@ Unreleased
|
||||||
- Add :meth:`Config.from_file` to load config using arbitrary file
|
- Add :meth:`Config.from_file` to load config using arbitrary file
|
||||||
loaders, such as ``toml.load`` or ``json.load``.
|
loaders, such as ``toml.load`` or ``json.load``.
|
||||||
:meth:`Config.from_json` is deprecated in favor of this. :pr:`3398`
|
: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
|
Version 1.1.2
|
||||||
|
|
|
||||||
|
|
@ -296,11 +296,15 @@ class DispatchingApp(object):
|
||||||
of the Werkzeug debugger means that it shows up in the browser.
|
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.loader = loader
|
||||||
self._app = None
|
self._app = None
|
||||||
self._lock = Lock()
|
self._lock = Lock()
|
||||||
self._bg_loading_exc_info = None
|
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:
|
if use_eager_loading:
|
||||||
self._load_unlocked()
|
self._load_unlocked()
|
||||||
else:
|
else:
|
||||||
|
|
@ -841,9 +845,6 @@ def run_command(
|
||||||
if debugger is None:
|
if debugger is None:
|
||||||
debugger = debug
|
debugger = debug
|
||||||
|
|
||||||
if eager_loading is None:
|
|
||||||
eager_loading = not reload
|
|
||||||
|
|
||||||
show_server_banner(get_env(), debug, info.app_import_path, eager_loading)
|
show_server_banner(get_env(), debug, info.app_import_path, eager_loading)
|
||||||
app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
|
app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue