Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support Cluster PubSub in asyncio#3736

Merged
petyaslavova merged 11 commits into
redis:masterfrom
abersheeran:asyncio-spubsub
Mar 26, 2026
Merged

Support Cluster PubSub in asyncio#3736
petyaslavova merged 11 commits into
redis:masterfrom
abersheeran:asyncio-spubsub

Conversation

@abersheeran

@abersheeran abersheeran commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

Pull Request check-list

Please make sure to review and check all of these items:

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

Support Cluster PubSub in asyncio


Note

Medium Risk
Adds new asyncio cluster pub/sub implementation with per-node routing and connection pool management; behavior changes around sharded subscribe/message filtering could impact pubsub consumers if edge cases exist.

Overview
Adds asyncio Redis Cluster pub/sub support via a new ClusterPubSub and a RedisCluster.pubsub() factory that can bind to a specific node (by ClusterNode or host/port) or lazily select one.

Extends asyncio PubSub to track shard channels (SSUBSCRIBE/SUNSUBSCRIBE), resubscribe them on reconnect, treat smessage as a publish event (including observability recording), and include shard subscriptions in the subscribed state.

Updates cluster command mixins so asyncio cluster clients include PubSubCommands, tightens sharded message filtering/round-robin generator behavior (avoids infinite loop when no node pubsubs exist), adds extensive asyncio cluster pubsub tests, and tweaks CI dependency-audit to ignore one additional CVE.

Written by Cursor Bugbot for commit 6371eb5. This will update automatically on new commits. Configure here.

@abersheeran abersheeran marked this pull request as ready for review August 13, 2025 15:28
@petyaslavova

Copy link
Copy Markdown
Collaborator

Hi @abersheeran, thank you for your contribution! We will review your changes soon.

@fcarne

fcarne commented Feb 17, 2026

Copy link
Copy Markdown

+1

@petyaslavova petyaslavova added the maintenance Maintenance (CI, Releases, etc) label Mar 24, 2026
Comment thread redis/asyncio/client.py Outdated
Comment thread redis/asyncio/cluster.py
Comment thread redis/asyncio/cluster.py Outdated
Comment thread redis/asyncio/cluster.py Outdated
Comment thread redis/asyncio/client.py
Comment thread redis/asyncio/cluster.py
Comment thread redis/asyncio/cluster.py Outdated
Comment thread redis/asyncio/cluster.py
@petyaslavova petyaslavova added techdebt Things that can be improved or refactored feature New feature and removed maintenance Maintenance (CI, Releases, etc) labels Mar 25, 2026
Comment thread redis/asyncio/cluster.py
Comment thread redis/asyncio/cluster.py Outdated
Comment thread redis/asyncio/cluster.py
Comment thread tests/test_asyncio/test_cluster.py Outdated
Comment thread tests/test_asyncio/test_cluster.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Comment thread redis/asyncio/cluster.py
@petyaslavova petyaslavova merged commit 78e332a into redis:master Mar 26, 2026
187 of 192 checks passed
@abersheeran abersheeran deleted the asyncio-spubsub branch March 26, 2026 17:16
@fbartonoctopus

Copy link
Copy Markdown

Hey @petyaslavova, I'm interested in using this to add support for Redis clusters to faststream (see issue)

I have seen that this is has been added to release 8.0.0b1

I have also seen that 8.0.0b2 is bringing a variety of breaking changes.

Is there any chance that async cluster pubsub could be included as a minor release for py-redis v7, or does it have to be delivered alongside the breaking changes in version 8? And if so, is there an estimated release date for py-redis v8?

@petyaslavova

Copy link
Copy Markdown
Collaborator

Hey @abersheeran, the biggest changes that were breaking in 8.0.0b2 - the ones related to command responses are reverted and 8.0.0 will be released without all those changed results object format changes. You can check the finilized changes related to protocol update in PR #4052

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature techdebt Things that can be improved or refactored

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants