File tree 2 files changed +30
-8
lines changed
2 files changed +30
-8
lines changed Original file line number Diff line number Diff line change @@ -5,15 +5,36 @@ def get_queue_index(name='default'):
5
5
"""
6
6
Returns the position of Queue for the named queue in QUEUES_LIST
7
7
"""
8
- queue_index = None
9
8
connection = get_connection (name )
10
- connection_kwargs = connection .connection_pool .connection_kwargs
9
+ connection_kwargs = dict (connection .connection_pool .connection_kwargs )
10
+
11
+ special_case_retry = False
12
+ if (retry := connection_kwargs .get ('retry' )) and retry .__class__ .__eq__ == object .__eq__ :
13
+ special_case_retry = True
14
+ del connection_kwargs ['retry' ]
15
+
11
16
for i in range (0 , 100 ):
12
17
try :
13
18
q = get_queue_by_index (i )
14
19
except AttributeError :
15
20
continue
16
- if q .name == name and q .connection .connection_pool .connection_kwargs == connection_kwargs :
17
- queue_index = i
18
- break
19
- return queue_index
21
+ if q .name == name :
22
+ # assert that the connection is correct
23
+ if special_case_retry :
24
+ q_connection_kwargs = dict (q .connection .connection_pool .connection_kwargs )
25
+ q_retry = q_connection_kwargs .pop ('retry' , None )
26
+ assert q_connection_kwargs == q_connection_kwargs
27
+ assert retry # for mypy
28
+ assert (
29
+ q_retry .__class__ == retry .__class__
30
+ and q_retry ._retries == retry ._retries
31
+ and set (q_retry ._supported_errors ) == set (retry ._supported_errors )
32
+ and q_retry ._backoff .__class__ == retry ._backoff .__class__
33
+ and q_retry ._backoff .__dict__ == retry ._backoff .__dict__
34
+ )
35
+ else :
36
+ assert q .connection .connection_pool .connection_kwargs == connection_kwargs
37
+
38
+ return i
39
+
40
+ return None
Original file line number Diff line number Diff line change @@ -67,9 +67,10 @@ def get_statistics(run_maintenance_tasks=False):
67
67
else :
68
68
oldest_job_timestamp = "-"
69
69
70
- # parse_class and connection_pool are not needed and not JSON serializable
71
- connection_kwargs .pop ('parser_class' , None )
70
+ # remove unneeded properties which are not serializable in JSON
72
71
connection_kwargs .pop ('connection_pool' , None )
72
+ connection_kwargs .pop ('parser_class' , None )
73
+ connection_kwargs .pop ('retry' , None )
73
74
74
75
queue_data = {
75
76
'name' : queue .name ,
You can’t perform that action at this time.
0 commit comments