MCPcopy
hub / github.com/encode/starlette / asgi

Function asgi

tests/test_testclient.py:238–248  ·  tests/test_testclient.py::asgi
(receive: Receive, send: Send)

Source from the content-addressed store, hash-verified

236 await websocket.send_json({class="st">"message": class="st">"test"})
237
238 async def asgi(receive: Receive, send: Send) -> None:
239 websocket = WebSocket(scope, receive=receive, send=send)
240 await websocket.accept()
241 async with anyio.create_task_group() as task_group:
242 task_group.start_soon(respond, websocket)
243 try:
244 class="cm"># this will block as the client does not send us data
245 class="cm"># it should not prevent `respond` from executing though
246 await websocket.receive_json()
247 except WebSocketDisconnect:
248 pass
249
250 return asgi
251

Callers

nothing calls this directly

Calls 3

acceptMethod · 0.95
receive_jsonMethod · 0.95
WebSocketClass · 0.90

Tested by

no test coverage detected