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.
()
| 468 | |
| 469 | |
| 470 | def 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 |
no test coverage detected
searching dependent graphs…