Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with RedisCluster and RedisDict's update #733

Open
mlasevich opened this issue Jan 31, 2024 · 0 comments
Open

Crash with RedisCluster and RedisDict's update #733

mlasevich opened this issue Jan 31, 2024 · 0 comments

Comments

@mlasevich
Copy link

mlasevich commented Jan 31, 2024

When using RedisDict with an instance of redis.cluster.RedisCluster() - a crash occurs
in base.py:

 Fraceback (most recent call last):
  File "/app/poc3.py", line 28, in <module>
    demo()
  File "/app/poc3.py", line 24, in demo
    data.update({'key': 'value'})
  File "/usr/local/lib/python3.9/site-packages/pottery/dict.py", line 144, in update
    with self._watch(arg) as pipeline:
  File "/usr/local/lib/python3.9/contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.9/site-packages/pottery/base.py", line 232, in _watch
    for context_manager in self.__context_managers(*others):
  File "/usr/local/lib/python3.9/site-packages/pottery/base.py", line 220, in __context_managers
    redises[connection_args(container.redis)].append(container)
  File "/usr/local/lib/python3.9/site-packages/pottery/base.py", line 89, in connection_args
    redis.connection_pool.connection_kwargs['host'],
AttributeError: 'RedisCluster' object has no attribute 'connection_pool'

To Reproduce

here is simple code to reproduce:

import os

from pottery import RedisDict

from redis.cluster import RedisCluster

env = os.environ

redis = RedisCluster(
    host=env.get('REDIS_HOST'),
    port=int(env.get('REDIS_PORT')),
    username=env.get('REDIS_USER'),
    password=env.get('REDIS_PASSWORD'),
    charset='utf-8',
    ssl_cert_reqs='none',
    ssl=True,
    skip_full_coverage_check=True
)


def demo():
    data = RedisDict(key=f"data:test", redis=redis)
    data.update({'key': 'value'})


if __name__ == "__main__":
    demo()

Expected behavior

I expect it to work same regardless if it is a cluster or a single Redis instance :-/

Environment (please complete the following information):

  • OS: Linux
  • Python version 3.9.18
  • Redis version : AWS MemoryDB 6.x cluster with a single node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant