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

Function process_events

example/django/notifications.py:48–64  ·  view source on GitHub ↗

Listen to events in Redis and process them.

()

Source from the content-addressed store, hash-verified

46
47
48async def process_events():
49 """Listen to events in Redis and process them."""
50 redis = aioredis.from_url("redis://127.0.0.1:6379/1")
51 pubsub = redis.pubsub()
52 await pubsub.subscribe("events")
53 async for message in pubsub.listen():
54 if message["type"] != "message":
55 continue
56 payload = message["data"].decode()
57 # Broadcast event to all users who have permissions to see it.
58 event = json.loads(payload)
59 recipients = (
60 websocket
61 for websocket, connection in CONNECTIONS.items()
62 if event["content_type_id"] in connection["content_type_ids"]
63 )
64 broadcast(recipients, payload)
65
66
67async def main():

Callers 1

mainFunction · 0.85

Calls 3

subscribeMethod · 0.80
broadcastFunction · 0.50
decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…