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

Function model_stream

src/py/reactpy/reactpy/backend/sanic.py:163–194  ·  view source on GitHub ↗
(
        request: request.Request[Any, Any],
        socket: WebSocketConnection,
        path: str = "",
    )

Source from the content-addressed store, hash-verified

161 options: Options,
162) -> None:
163 async def model_stream(
164 request: request.Request[Any, Any],
165 socket: WebSocketConnection,
166 path: str = "",
167 ) -> None:
168 asgi_app = getattr(request.app, "_asgi_app", None)
169 scope = asgi_app.transport.scope if asgi_app else {}
170 if not scope: # nocov
171 logger.warning("No scope. Sanic may not be running with an ASGI server")
172
173 send, recv = _make_send_recv_callbacks(socket)
174 await serve_layout(
175 Layout(
176 ConnectionContext(
177 constructor(),
178 value=Connection(
179 scope=scope,
180 location=Location(
181 pathname=f"/{path[len(options.url_prefix):]}",
182 search=(
183 f"?{request.query_string}"
184 if request.query_string
185 else ""
186 ),
187 ),
188 carrier=_SanicCarrier(request, socket),
189 ),
190 )
191 ),
192 send,
193 recv,
194 )
195
196 api_blueprint.add_websocket_route(
197 model_stream,

Callers

nothing calls this directly

Calls 7

serve_layoutFunction · 0.90
LayoutClass · 0.90
ConnectionClass · 0.90
LocationClass · 0.90
_SanicCarrierClass · 0.85
constructorFunction · 0.50

Tested by

no test coverage detected