MCPcopy Index your code
hub / github.com/reactive-python/reactpy / model_stream

Function model_stream

src/py/reactpy/reactpy/backend/starlette.py:141–170  ·  view source on GitHub ↗
(socket: WebSocket)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 7

serve_layoutFunction · 0.90
LayoutClass · 0.90
ConnectionClass · 0.90
LocationClass · 0.90
componentFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected