From a1c3093d70acec8cd06b958b4b33acef11ded4df Mon Sep 17 00:00:00 2001 From: "Terence D. Honles" Date: Fri, 2 May 2025 09:27:11 +0200 Subject: [PATCH] fix JSON stats view and tests with redis-py 6.0 x-ref: https://github.com/redis/redis-py/pull/3622 --- django_rq/tests/utils.py | 13 ++++++++----- django_rq/utils.py | 5 +++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/django_rq/tests/utils.py b/django_rq/tests/utils.py index afe4df2a..8b467f7a 100644 --- a/django_rq/tests/utils.py +++ b/django_rq/tests/utils.py @@ -5,15 +5,18 @@ def get_queue_index(name='default'): """ Returns the position of Queue for the named queue in QUEUES_LIST """ - queue_index = None connection = get_connection(name) connection_kwargs = connection.connection_pool.connection_kwargs + for i in range(0, 100): try: q = get_queue_by_index(i) except AttributeError: continue - if q.name == name and q.connection.connection_pool.connection_kwargs == connection_kwargs: - queue_index = i - break - return queue_index + if q.name == name: + # assert that the connection is correct + assert q.connection.connection_pool.connection_kwargs == connection_kwargs + + return i + + return None diff --git a/django_rq/utils.py b/django_rq/utils.py index d5b0a536..36b92368 100644 --- a/django_rq/utils.py +++ b/django_rq/utils.py @@ -67,9 +67,10 @@ def get_statistics(run_maintenance_tasks=False): else: oldest_job_timestamp = "-" - # parse_class and connection_pool are not needed and not JSON serializable - connection_kwargs.pop('parser_class', None) + # remove unneeded properties which are not serializable in JSON connection_kwargs.pop('connection_pool', None) + connection_kwargs.pop('parser_class', None) + connection_kwargs.pop('retry', None) queue_data = { 'name': queue.name,