diff options
author | Selwin Ong <selwin.ong@gmail.com> | 2020-08-16 11:23:29 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-16 11:23:29 +0700 |
commit | 39fb709c10461340adb5f9f852d1483607c28a6f (patch) | |
tree | 9bb088b5c282044ac4bec520cf6374caff7a7553 /rq/utils.py | |
parent | 7bf100ebe794179847b774f458857fb3bc6234c2 (diff) | |
download | rq-39fb709c10461340adb5f9f852d1483607c28a6f.tar.gz |
get_redis_server_version() should handle 4 digit version numbers (#1322)
Diffstat (limited to 'rq/utils.py')
-rw-r--r-- | rq/utils.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/rq/utils.py b/rq/utils.py index 4a22880..fd78ecb 100644 --- a/rq/utils.py +++ b/rq/utils.py @@ -14,10 +14,9 @@ import importlib import logging import numbers import sys -try: - from collections.abc import Iterable -except ImportError: - from collections import Iterable + +from collections import Iterable +from distutils.version import StrictVersion from .compat import as_text, is_python_version, string_types from .exceptions import TimeoutFormatError @@ -248,3 +247,12 @@ def parse_timeout(timeout): 'such as "1h", "23m".') return timeout + + +def get_version(connection): + """ + Return 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 |