Skip to content

Instantly share code, notes, and snippets.

@ankitml
Created February 6, 2019 22:13
Show Gist options
  • Save ankitml/0c3543c6a4a283e82aff55c18f76befc to your computer and use it in GitHub Desktop.
Save ankitml/0c3543c6a4a283e82aff55c18f76befc to your computer and use it in GitHub Desktop.
Websocet tutorial 5: Redis relay
from aioredis.pubsub import Receiver
REDIS_URL = 'localhost'
REDIS_PORT = 6379
async def redis_relay(websocket):
    conn = aioredis.create_connection((REDIS_URL, REDIS_PORT))
    receiver = Receiver()
    connection.execute_pubsub('subscribe', receiver.channel(‘updates’))
while (await receiver.wait_message()):
message = await receiver.get()
await websocket.send(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment