This repository was archived by the owner on Aug 19, 2025. It is now read-only.
Add redis backed with RedisPy #91
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rationale
Broadcaster uses
asyncio-redisin itsRedisBackend.asyncio-redisis not actively maintained at the moment.RedisPy(https://github.com/redis/redis-py) is the maintained Redis client for Python, and it has had AsyncIO support for quite some time.Pull Request Content
This PR provides an updated Redis backend using
RedisPy.Problems faced
RedisPydoesn't allow listening for PubSub messages if the connection is not subscribed to any channels:https://github.com/redis/redis-py/blob/master/redis/asyncio/client.py#L807
To solve this, the code of the
Broadcasterclass has been changed to start the listener task only after the first subscription to a channel.Another solution would be to subscribe to an arbitrary channel in the
connectmethod of Redis backend. I am not sure that I like this workaround.However, I have not tested that these changes to the
Broadcasterclass do not break other backends.