MCPcopy Create free account
hub / github.com/pallets/quart / has_app_context

Function has_app_context

src/quart/ctx.py:438–451  ·  view source on GitHub ↗

Check if execution is within an app context. This allows a controlled way to act if there is an app context available, or silently not act if not. For example, .. code-block:: python if has_app_context(): log.info("Executing in %s context", current_app.name) S

()

Source from the content-addressed store, hash-verified

436
437
438def has_app_context() -> bool:
439 """Check if execution is within an app context.
440
441 This allows a controlled way to act if there is an app context
442 available, or silently not act if not. For example,
443
444 .. code-block:: python
445
446 if has_app_context():
447 log.info("Executing in %s context", current_app.name)
448
449 See also :func:`has_request_context`
450 """
451 return _cv_app.get(None) is not None
452
453
454def has_request_context() -> bool:

Callers 4

test_has_request_contextFunction · 0.90
test_has_app_contextFunction · 0.90
copy_current_app_contextFunction · 0.85

Calls 1

getMethod · 0.45

Tested by 2

test_has_request_contextFunction · 0.72
test_has_app_contextFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…