Bump Redis client version to 4.1.1
Bump Redis client version to the latest 4.1.1 version and replace
deprecated Redis client '_compat' module with 'utils' module.
SDLPY version: 3.0.2
Issue-Id: RIC-698
Signed-off-by: Timo Tietavainen <timo.tietavainen@nokia.com>
Change-Id: I1d15bc2ea1a11d4cf1e3fafac53ee584b373a7c4
diff --git a/ricsdl-package/ricsdl/backend/redis.py b/ricsdl-package/ricsdl/backend/redis.py
index 1c549db..3ebc8cb 100755
--- a/ricsdl-package/ricsdl/backend/redis.py
+++ b/ricsdl-package/ricsdl/backend/redis.py
@@ -28,7 +28,7 @@
from redis import Redis
from redis.sentinel import Sentinel
from redis.lock import Lock
-from redis._compat import nativestr
+from redis.utils import str_if_bytes
from redis import exceptions as redis_exceptions
from ricsdl.configuration import _Configuration
from ricsdl.exceptions import (
@@ -69,7 +69,7 @@
Adapted from: https://github.com/andymccurdy/redis-py/blob/master/redis/client.py
"""
- message_type = nativestr(response[0])
+ message_type = str_if_bytes(response[0])
if message_type == 'pmessage':
message = {
'type': message_type,
@@ -392,7 +392,7 @@
new_sentinel = Sentinel([sentinel_node])
new_redis = new_sentinel.master_for(master_name)
- new_redis.set_response_callback('SETIE', lambda r: r and nativestr(r) == 'OK' or False)
+ new_redis.set_response_callback('SETIE', lambda r: r and str_if_bytes(r) == 'OK' or False)
new_redis.set_response_callback('DELIE', lambda r: r and int(r) == 1 or False)
redis_pubsub = PubSub(self.event_separator, new_redis.connection_pool, ignore_subscribe_messages=True)