From 6028a636073909c6472703f4c42b610a70b1f889 Mon Sep 17 00:00:00 2001 From: Selwin Ong Date: Fri, 21 Aug 2020 09:21:49 +0700 Subject: [PATCH] Restores compatibility with fakeredis (#1324) --- rq/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rq/utils.py b/rq/utils.py index fd78ecb..01a4ab0 100644 --- a/rq/utils.py +++ b/rq/utils.py @@ -18,6 +18,8 @@ import sys from collections import Iterable from distutils.version import StrictVersion +from redis.exceptions import ResponseError + from .compat import as_text, is_python_version, string_types from .exceptions import TimeoutFormatError @@ -251,8 +253,11 @@ def parse_timeout(timeout): def get_version(connection): """ - Return StrictVersion of Redis server version. + Returns StrictVersion of Redis server version. This function also correctly handles 4 digit redis server versions. """ - version_string = connection.info("server")["redis_version"] - return StrictVersion('.'.join(version_string.split('.')[:3])) \ No newline at end of file + try: + version_string = connection.info("server")["redis_version"] + except ResponseError: # fakeredis doesn't implement Redis' INFO command + version_string = "5.0.9" + return StrictVersion('.'.join(version_string.split('.')[:3]))