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,