MCPcopy Create free account
hub / github.com/aio-libs/aiohttp / websocket_handler

Function websocket_handler

tests/test_web_websocket_functional.py:1249–1261  ·  view source on GitHub ↗
(request: web.Request)

Source from the content-addressed store, hash-verified

1247 app[shutdown_websockets] = weakref.WeakSet()
1248
1249 async def websocket_handler(request: web.Request) -> web.WebSocketResponse:
1250 websocket = web.WebSocketResponse()
1251 await websocket.prepare(request)
1252 request.app[websockets].add(websocket)
1253 request.app[shutdown_websockets].add(websocket)
1254
1255 try:
1256 async for message in websocket:
1257 await websocket.send_json({"ok": True, "message": message.json()})
1258 finally:
1259 request.app[websockets].discard(websocket)
1260
1261 return websocket
1262
1263 async def on_shutdown(app: web.Application) -> None:
1264 while app[shutdown_websockets]:

Callers

nothing calls this directly

Calls 10

prepareMethod · 0.95
send_jsonMethod · 0.95
receiveMethod · 0.95
send_bytesMethod · 0.95
closeMethod · 0.95
send_strMethod · 0.95
receive_strMethod · 0.95
receive_jsonMethod · 0.95
addMethod · 0.80
jsonMethod · 0.45

Tested by

no test coverage detected