MCPcopy
hub / github.com/plotly/dash / websocket

Method websocket

dash/_callback_context.py:333–355  ·  view source on GitHub ↗

Get WebSocket interface if running in WebSocket context. Returns the DashWebsocketCallback instance if the callback is being executed via WebSocket, otherwise returns None. Raises: RuntimeError: If websocket_callbacks is requested but the backend

(self)

Source from the content-addressed store, hash-verified

331 @property
332 @has_context
333 def websocket(self) -> typing.Optional[DashWebsocketCallback]:
334 """Get WebSocket interface if running in WebSocket context.
335
336 Returns the DashWebsocketCallback instance if the callback is being
337 executed via WebSocket, otherwise returns None.
338
339 Raises:
340 RuntimeError: If websocket_callbacks is requested but the backend
341 doesn't support WebSocket.
342 """
343 ws = _get_from_context("dash_websocket", None)
344 if ws is None:
345 app = get_app()
346 if (
347 hasattr(app, "_websocket_callbacks")
348 and app._websocket_callbacks # pylint: disable=protected-access
349 and not app.backend.websocket_capability
350 ):
351 raise RuntimeError(
352 f"WebSocket callbacks requested but backend "
353 f"'{app.backend.server_type}' doesn't support them."
354 )
355 return ws
356
357
358callback_context = CallbackContext()

Callers

nothing calls this directly

Calls 2

get_appFunction · 0.90
_get_from_contextFunction · 0.85

Tested by

no test coverage detected