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

Handle the case where the connection to redis instances use Sentinels in get_scheduler_statistics() #671

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion django_rq/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.core.exceptions import ImproperlyConfigured
from django.db import connections
from redis.sentinel import SentinelConnectionPool
from rq.command import send_stop_job_command
from rq.job import Job
from rq.registry import (
Expand Down Expand Up @@ -102,7 +103,11 @@ def get_scheduler_statistics():
# to handle the possibility of a configuration with multiple redis connections and scheduled
# jobs in more than one of them
queue = get_queue_by_index(index)
connection = queue.connection.connection_pool.connection_kwargs
if isinstance(queue.connection.connection_pool, SentinelConnectionPool):
first_sentinel = queue.connection.connection_pool.sentinel_manager.sentinels[0]
connection = first_sentinel.connection_pool.connection_kwargs
else:
connection = queue.connection.connection_pool.connection_kwargs
conn_key = f"{connection['host']}:{connection.get('port', 6379)}/{connection.get('db', 0)}"
if conn_key not in schedulers:
try:
Expand Down
Loading