MCPcopy Index your code
hub / github.com/python-websockets/websockets / handler

Function handler

example/django/notifications.py:32–45  ·  view source on GitHub ↗

Authenticate user and register connection in CONNECTIONS.

(websocket)

Source from the content-addressed store, hash-verified

30
31
32async def handler(websocket):
33 """Authenticate user and register connection in CONNECTIONS."""
34 sesame = await websocket.recv()
35 user = await asyncio.to_thread(get_user, sesame)
36 if user is None:
37 await websocket.close(CloseCode.INTERNAL_ERROR, "authentication failed")
38 return
39
40 ct_ids = await asyncio.to_thread(get_content_types, user)
41 CONNECTIONS[websocket] = {"content_type_ids": ct_ids}
42 try:
43 await websocket.wait_closed()
44 finally:
45 del CONNECTIONS[websocket]
46
47
48async def process_events():

Callers

nothing calls this directly

Calls 3

recvMethod · 0.45
closeMethod · 0.45
wait_closedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…