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
()
| 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 |
no outgoing calls
no test coverage detected
searching dependent graphs…