Skip to content

fix JSON stats view and tests with redis-py 6.0 #706

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
13 changes: 8 additions & 5 deletions django_rq/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this to only check the name, since this method was skipping the queue (and breaking on an IndexError if the connection wasn't the "same")

# assert that the connection is correct
assert q.connection.connection_pool.connection_kwargs == connection_kwargs

return i

return None
5 changes: 3 additions & 2 deletions django_rq/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to try to serialize this?


queue_data = {
'name': queue.name,
Expand Down
Loading