Returns the position of Queue for the named queue in QUEUES_LIST
(name='default')
| 24 | |
| 25 | |
| 26 | def get_queue_index(name='default'): |
| 27 | """ |
| 28 | Returns the position of Queue for the named queue in QUEUES_LIST |
| 29 | """ |
| 30 | connection = get_connection(name) |
| 31 | connection_kwargs = connection.connection_pool.connection_kwargs |
| 32 | |
| 33 | for i in range(0, 100): |
| 34 | try: |
| 35 | q = get_queue_by_index(i) |
| 36 | except AttributeError: |
| 37 | continue |
| 38 | if q.name == name: |
| 39 | # assert that the connection is correct |
| 40 | pool_kwargs = q.connection.connection_pool.connection_kwargs |
| 41 | if not _is_buggy_retry(pool_kwargs) or not _is_buggy_retry(connection_kwargs): |
| 42 | assert pool_kwargs == connection_kwargs |
| 43 | else: |
| 44 | # patch the retry backoff since there is a bug in the default |
| 45 | # backoff strategy |
| 46 | # |
| 47 | # fixed in https://github.com/redis/redis-py/pull/3668 |
| 48 | with patch.object(pool_kwargs['retry'], '_backoff', NoBackoff()): |
| 49 | with patch.object(connection_kwargs['retry'], '_backoff', NoBackoff()): |
| 50 | assert pool_kwargs == connection_kwargs |
| 51 | |
| 52 | assert pool_kwargs['retry']._backoff.__dict__ == connection_kwargs['retry']._backoff.__dict__ |
| 53 | |
| 54 | return i |
| 55 | |
| 56 | return None |
| 57 | |
| 58 | |
| 59 | def flush_registry(registry): |
searching dependent graphs…