diff --git a/kombu/transport/redis.py b/kombu/transport/redis.py index b6fa101d9..912b0fe0e 100644 --- a/kombu/transport/redis.py +++ b/kombu/transport/redis.py @@ -1429,7 +1429,7 @@ def _sentinel_managed_pool(self, asynchronous=False): return sentinel_inst.master_for( master_name, - self.Client, + redis.Redis, ).connection_pool def _get_pool(self, asynchronous=False): diff --git a/t/unit/transport/test_redis.py b/t/unit/transport/test_redis.py index ecbed7eb0..993ae445d 100644 --- a/t/unit/transport/test_redis.py +++ b/t/unit/transport/test_redis.py @@ -1734,6 +1734,44 @@ def test_sentinel_with_ssl(self): assert (params['connection_class'] is SentinelManagedSSLConnection) + def test_can_create_connection_with_global_keyprefix(self): + from redis.exceptions import ConnectionError + + try: + connection = Connection( + 'sentinel://localhost:65534/', + transport_options={ + 'global_keyprefix': 'some_prefix', + 'master_name': 'not_important', + }, + ) + with pytest.raises(ConnectionError): + connection.channel() + finally: + connection.close() + + def test_can_create_correct_mixin_with_global_keyprefix(self): + from kombu.transport.redis import GlobalKeyPrefixMixin + + with patch('redis.sentinel.Sentinel'): + connection = Connection( + 'sentinel://localhost:65534/', + transport_options={ + 'global_keyprefix': 'some_prefix', + 'master_name': 'not_important', + }, + ) + + assert isinstance( + connection.channel().client, + GlobalKeyPrefixMixin + ) + assert ( + connection.channel().client.global_keyprefix + == 'some_prefix' + ) + connection.close() + class test_GlobalKeyPrefixMixin: