From dd8da547c44f03458441fee999f168727220c2ca Mon Sep 17 00:00:00 2001 From: Carmen Date: Wed, 11 Dec 2024 12:37:04 +0100 Subject: [PATCH] use valkey python module instead of redis --- pyproject.toml | 2 ++ src/actinia_core/core/common/redis_base.py | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8f2db4f90..9bdb04a43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,6 +71,7 @@ dependencies = [ "pandas", "sentinelsat", "tqdm", + "valkey", ] [project.optional-dependencies] @@ -79,6 +80,7 @@ plugins = [ # "actinia-metadata-plugin @ https://github.com/actinia-org/actinia-metadata-plugin/releases/download/1.0.2/actinia_metadata_plugin.wsgi-1.0.2-py2.py3-none-any.whl", # "actinia-satellite-plugin @ https://github.com/actinia-org/actinia_satellite_plugin/releases/download/0.1.0/actinia_satellite_plugin-0.1.0-py2.py3-none-any.whl", # "actinia-statistic-plugin @ https://github.com/actinia-org/actinia_statistic_plugin/releases/download/0.2.0/actinia_statistic_plugin-0.2.0-py2.py3-none-any.whl", + "valkey-cli", ] [project.scripts] diff --git a/src/actinia_core/core/common/redis_base.py b/src/actinia_core/core/common/redis_base.py index 7ee17b6fc..6508110c5 100644 --- a/src/actinia_core/core/common/redis_base.py +++ b/src/actinia_core/core/common/redis_base.py @@ -25,7 +25,7 @@ Redis base class """ -import redis +import valkey from actinia_core.core.logging_interface import log __license__ = "GPLv3" @@ -60,18 +60,18 @@ def connect(self, host="localhost", port=6379, password=None): kwargs["port"] = port if password and password is not None: kwargs["password"] = password - self.connection_pool = redis.ConnectionPool(**kwargs) + self.connection_pool = valkey.ConnectionPool(**kwargs) del kwargs - self.redis_server = redis.StrictRedis( + self.redis_server = valkey.StrictRedis( connection_pool=self.connection_pool ) try: self.redis_server.ping() - except redis.exceptions.ResponseError as e: + except valkey.exceptions.ResponseError as e: log.error("Could not connect to " + host, port, str(e)) - except redis.exceptions.AuthenticationError: + except valkey.exceptions.AuthenticationError: log.error("Invalid password") - except redis.exceptions.ConnectionError as e: + except valkey.exceptions.ConnectionError as e: log.error(str(e)) def disconnect(self):