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

Function has_websocket_context

src/quart/ctx.py:470–483  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

468
469
470def has_websocket_context() -> bool:
471 """Check if execution is within a websocket context.
472
473 This allows a controlled way to act if there is a websocket
474 context available, or silently not act if not. For example,
475
476 .. code-block:: python
477
478 if has_websocket_context():
479 log.info("Websocket endpoint %s", websocket.endpoint)
480
481 See also :func:`has_app_context`.
482 """
483 return _cv_websocket.get(None) is not None

Callers 5

handle_http_exceptionMethod · 0.85
handle_user_exceptionMethod · 0.85
log_exceptionMethod · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…