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

Function has_request_context

src/quart/ctx.py:454–467  ·  view source on GitHub ↗

Check if execution is within a request context. This allows a controlled way to act if there is a request context available, or silently not act if not. For example, .. code-block:: python if has_request_context(): log.info("Request endpoint %s", request.endpoint)

()

Source from the content-addressed store, hash-verified

452
453
454def has_request_context() -> bool:
455 """Check if execution is within a request context.
456
457 This allows a controlled way to act if there is a request context
458 available, or silently not act if not. For example,
459
460 .. code-block:: python
461
462 if has_request_context():
463 log.info("Request endpoint %s", request.endpoint)
464
465 See also :func:`has_app_context`.
466 """
467 return _cv_request.get(None) is not None
468
469
470def has_websocket_context() -> bool:

Callers 8

test_has_request_contextFunction · 0.90
_streamFunction · 0.85
handle_http_exceptionMethod · 0.85
handle_user_exceptionMethod · 0.85
log_exceptionMethod · 0.85

Calls 1

getMethod · 0.45

Tested by 1

test_has_request_contextFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…