rq / django-rq

A simple app that provides django integration for RQ (Redis Queue)
MIT License
1.82k stars 286 forks source link

Sentinel settings don't work #565

Open MSMikl opened 1 year ago

MSMikl commented 1 year ago

https://github.com/rq/django-rq/blob/e05eb8a21853ac3946815291d22b4e975e91035d/django_rq/queues.py#L113-L123

There are couple errors in Sentinel connection creating.

  1. According to official Python redis docs, you should call Sentinel with passing dicitonary to parameter sentinel_kwargs, not parameters from this dict themselves
  2. To make connection work you should pass parameter "password" to sentinel.master_for() method

For my project I just corrected queues.py myself and replaced old queues.py Correct code below

    if 'SENTINELS' in config:
        sentinel_kwargs = {
            'db': config.get('DB'),
            'password': config.get('PASSWORD'),
            'socket_timeout': config.get('SOCKET_TIMEOUT'),
        }
        sentinel_kwargs.update(config.get('CONNECTION_KWARGS', {}))
        sentinel = Sentinel(config['SENTINELS'], sentinel_kwargs=sentinel_kwargs)
        return sentinel.master_for(
            service_name=config['MASTER_NAME'], redis_class=redis_cls, password=config.get('PASSWORD')
        )
selwin commented 1 year ago

Do you mind opening a PR for this? I'd like to cut a new release sometime next week.