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
()
| 436 | |
| 437 | |
| 438 | def 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 | |
| 454 | def has_request_context() -> bool: |
searching dependent graphs…