forked from orbit-oss/flask
Merge pull request #4461 from pallets/cli-lazy-context
lazy loading preserves click context
This commit is contained in:
commit
4843590c4a
2 changed files with 11 additions and 0 deletions
|
|
@ -42,6 +42,9 @@ Unreleased
|
|||
- Add an ``--exclude-patterns`` option to the ``flask run`` CLI
|
||||
command to specify patterns that will be ignored by the reloader.
|
||||
:issue:`4188`
|
||||
- When using lazy loading (the default with the debugger), the Click
|
||||
context from the ``flask run`` command remains available in the
|
||||
loader thread. :issue:`4460`
|
||||
|
||||
|
||||
Version 2.0.3
|
||||
|
|
|
|||
|
|
@ -301,9 +301,17 @@ class DispatchingApp:
|
|||
self._load_in_background()
|
||||
|
||||
def _load_in_background(self):
|
||||
# Store the Click context and push it in the loader thread so
|
||||
# script_info is still available.
|
||||
ctx = click.get_current_context(silent=True)
|
||||
|
||||
def _load_app():
|
||||
__traceback_hide__ = True # noqa: F841
|
||||
|
||||
with self._lock:
|
||||
if ctx is not None:
|
||||
click.globals.push_context(ctx)
|
||||
|
||||
try:
|
||||
self._load_unlocked()
|
||||
except Exception as e:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue