|
2 | 2 | from math import ceil
|
3 | 3 | from typing import Tuple, Optional
|
4 | 4 |
|
5 |
| -import redis |
6 | 5 | from django.contrib import admin, messages
|
7 | 6 | from django.contrib.admin.views.decorators import staff_member_required
|
8 | 7 | from django.core.paginator import Paginator
|
|
14 | 13 | from django.views.decorators.cache import never_cache
|
15 | 14 | from redis.exceptions import ResponseError
|
16 | 15 |
|
17 |
| -from .queues import get_all_workers, get_connection, QueueNotFoundError |
| 16 | +ResponseErrors = {ResponseError} |
| 17 | +try: |
| 18 | + from valkey import exceptions |
| 19 | + ResponseErrors.add(exceptions.ResponseError) |
| 20 | +except ImportError: |
| 21 | + pass |
| 22 | + |
| 23 | +from .queues import get_all_workers, get_connection, QueueNotFoundError, ConnectionErrors |
18 | 24 | from .queues import get_queue as get_queue_base
|
19 | 25 | from .rq_classes import JobExecution, DjangoWorker, DjangoQueue, InvalidJobOperation
|
20 | 26 | from .settings import SCHEDULER_CONFIG, logger
|
@@ -71,7 +77,7 @@ def get_statistics(run_maintenance_tasks=False):
|
71 | 77 | if run_maintenance_tasks:
|
72 | 78 | queue.clean_registries()
|
73 | 79 |
|
74 |
| - # Raw access to the first item from left of the redis list. |
| 80 | + # Raw access to the first item from left of the broker list. |
75 | 81 | # This might not be accurate since new job can be added from the left
|
76 | 82 | # with `at_front` parameters.
|
77 | 83 | # Ideally rq should supports Queue.oldest_job
|
@@ -102,7 +108,7 @@ def get_statistics(run_maintenance_tasks=False):
|
102 | 108 | canceled_jobs=len(queue.canceled_job_registry),
|
103 | 109 | )
|
104 | 110 | queues.append(queue_data)
|
105 |
| - except redis.ConnectionError as e: |
| 111 | + except ConnectionErrors as e: |
106 | 112 | logger.error(f"Could not connect for queue {queue_name}: {e}")
|
107 | 113 | continue
|
108 | 114 |
|
@@ -277,7 +283,7 @@ def clear_queue_registry(request: HttpRequest, queue_name: str, registry_name: s
|
277 | 283 | for job_id in job_ids:
|
278 | 284 | registry.remove(job_id, delete_job=True)
|
279 | 285 | messages.info(request, f"You have successfully cleared the {registry_name} jobs in queue {queue.name}")
|
280 |
| - except ResponseError as e: |
| 286 | + except ResponseErrors as e: |
281 | 287 | messages.error(
|
282 | 288 | request,
|
283 | 289 | f"error: {e}",
|
|
0 commit comments