Created
February 6, 2019 22:13
-
-
Save ankitml/0c3543c6a4a283e82aff55c18f76befc to your computer and use it in GitHub Desktop.
Websocet tutorial 5: Redis relay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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