Skip to content

Commit

Permalink
lazy load app on reload only
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Nov 19, 2019
1 parent a83d6d2 commit 240a110
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/flask/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 240a110

Please sign in to comment.