-
-
Save whitespy/cbe8b38122ff83bc0500cd2ba1ecb4df to your computer and use it in GitHub Desktop.
pubsub.py
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
| async with app["redis_connection"].pubsub() as pubsub: | |
| await pubsub.psubscribe("applicants:*") | |
| try: | |
| while True: | |
| message = await pubsub.get_message(ignore_subscribe_messages=True) | |
| if message is not None: | |
| for ws in app["websockets"].get(message["channel"], []): | |
| if not ws.closed: | |
| await ws.send_json(message["data"]) | |
| except asyncio.CancelledError: | |
| pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment