(socket: WebSocket)
| 139 | options: Options, app: Starlette, component: RootComponentConstructor |
| 140 | ) -> None: |
| 141 | async def model_stream(socket: WebSocket) -> None: |
| 142 | await socket.accept() |
| 143 | send, recv = _make_send_recv_callbacks(socket) |
| 144 | |
| 145 | pathname = "/" + socket.scope["path_params"].get("path", "") |
| 146 | pathname = pathname[len(options.url_prefix) :] or "/" |
| 147 | search = socket.scope["query_string"].decode() |
| 148 | |
| 149 | try: |
| 150 | await serve_layout( |
| 151 | Layout( |
| 152 | ConnectionContext( |
| 153 | component(), |
| 154 | value=Connection( |
| 155 | scope=socket.scope, |
| 156 | location=Location(pathname, f"?{search}" if search else ""), |
| 157 | carrier=socket, |
| 158 | ), |
| 159 | ) |
| 160 | ), |
| 161 | send, |
| 162 | recv, |
| 163 | ) |
| 164 | except BaseExceptionGroup as egroup: |
| 165 | for e in egroup.exceptions: |
| 166 | if isinstance(e, WebSocketDisconnect): |
| 167 | logger.info(f"WebSocket disconnect: {e.code}") |
| 168 | break |
| 169 | else: # nocov |
| 170 | raise |
| 171 | |
| 172 | app.add_websocket_route(str(STREAM_PATH), model_stream) |
| 173 | app.add_websocket_route(f"{STREAM_PATH}/{{path:path}}", model_stream) |
nothing calls this directly
no test coverage detected