MCPcopy Index your code
hub / github.com/plotly/dash / _get_or_create_session_id

Function _get_or_create_session_id

dash/mcp/_server.py:53–66  ·  view source on GitHub ↗

Creates a shared session ID shared across all clients. The session is used to notify clients of app restarts so they can refresh their view of the app. When hot-reloading is enabled, the reload_hash is used Otherwise, the parent PID is used because it is a st

()

Source from the content-addressed store, hash-verified

51 """Add MCP routes to a Dash app."""
52
53 def _get_or_create_session_id() -> str:
54 """
55 Creates a shared session ID shared across all clients. The session is
56 used to notify clients of app restarts so they can refresh their view
57 of the app.
58 When hot-reloading is enabled, the reload_hash is used
59 Otherwise, the parent PID is used because it is a stable identifier
60 across different worker processes.
61 """
62 # pylint: disable=protected-access
63 reload_hash = app._hot_reload.hash
64 if reload_hash is not None:
65 return reload_hash
66 return hashlib.sha256(f"dash-mcp-{os.getppid()}".encode()).hexdigest()[:32]
67
68 _session_id: str = _get_or_create_session_id()
69

Callers 2

enable_mcp_serverFunction · 0.85
_check_sessionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…