Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the latest redis module, suports RedisCluster natively. #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions celery_redis_cluster_backend/redis_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from celery.backends.base import KeyValueStoreBackend

# try:
from rediscluster.client import RedisCluster
import redis
# from kombu.transport.redis import get_redis_error_classes
# except ImportError: # pragma: no cover
# RedisCluster = None # noqa
Expand All @@ -34,20 +34,13 @@

__all__ = ['RedisClusterBackend']

REDIS_MISSING = """\
You need to install the redis-py-cluster library in order to use \
the Redis result store backend."""

logger = get_logger(__name__)
error = logger.error


class RedisClusterBackend(KeyValueStoreBackend):
"""Redis task result store."""

#: redis client module.
redis = RedisCluster

startup_nodes = None
max_connections = None
init_slot_cache = True
Expand All @@ -60,9 +53,6 @@ def __init__(self, *args, **kwargs):
super(RedisClusterBackend, self).__init__(expires_type=int, **kwargs)
conf = self.app.conf

if self.redis is None:
raise ImproperlyConfigured(REDIS_MISSING)

# For compatibility with the old REDIS_* configuration keys.
def _get(key):
for prefix in 'CELERY_REDIS_{0}', 'REDIS_{0}':
Expand Down Expand Up @@ -209,7 +199,7 @@ def _new_chord_return(self, task, state, result, propagate=None,

@cached_property
def client(self):
return RedisCluster(**self.conn_params)
return redis.RedisCluster(**self.conn_params)

def __reduce__(self, args=(), kwargs={}):
return super(RedisClusterBackend, self).__reduce__(
Expand Down
2 changes: 1 addition & 1 deletion requirments.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
celery==5.2.7
redis-py-cluster==2.1.3
redis==4.5.1