Skip to content

Commit f78c440

Browse files
woutdenolfauvipy
andauthored
redis.connection.ConnectionPool API change: get_connection does not accept arguments (#2294)
* redis.connection.ConnectionPool API change: get_connection does not accept arguments --------- Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
1 parent 029f7ca commit f78c440

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

kombu/transport/redis.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@
5959
from bisect import bisect
6060
from collections import namedtuple
6161
from contextlib import contextmanager
62+
from importlib.metadata import version
6263
from queue import Empty
6364
from time import time
6465

66+
from packaging.version import Version
6567
from vine import promise
6668

6769
from kombu.exceptions import InconsistencyError, VersionMismatch
@@ -79,8 +81,10 @@
7981

8082
try:
8183
import redis
84+
_REDIS_GET_CONNECTION_WITHOUT_ARGS = Version(version("redis")) >= Version("5.3.0")
8285
except ImportError: # pragma: no cover
8386
redis = None
87+
_REDIS_GET_CONNECTION_WITHOUT_ARGS = None
8488

8589
try:
8690
from redis import sentinel
@@ -511,7 +515,10 @@ def _unregister(self, channel, client, type):
511515

512516
def _client_registered(self, channel, client, cmd):
513517
if getattr(client, 'connection', None) is None:
514-
client.connection = client.connection_pool.get_connection('_')
518+
if _REDIS_GET_CONNECTION_WITHOUT_ARGS:
519+
client.connection = client.connection_pool.get_connection()
520+
else:
521+
client.connection = client.connection_pool.get_connection('_')
515522
return (client.connection._sock is not None and
516523
(channel, client, cmd) in self._chan_to_sock)
517524

requirements/default.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ amqp>=5.1.1,<6.0.0
22
vine==5.1.0
33
backports.zoneinfo[tzdata]>=0.2.1; python_version<"3.9"
44
tzdata>=2025.2; python_version>="3.9"
5+
packaging

0 commit comments

Comments
 (0)