mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-25 10:48:12 +08:00
uses disque_nodes convention
This commit is contained in:
@@ -139,7 +139,7 @@ def get_broker(list_key=Conf.PREFIX):
|
||||
if Conf.IRONMQ:
|
||||
from brokers import iron_mq
|
||||
return iron_mq.IronMQBroker(list_key=list_key)
|
||||
elif Conf.DISQUE:
|
||||
elif Conf.DISQUE_NODES:
|
||||
from brokers import disque
|
||||
return disque.Disque(list_key=list_key)
|
||||
elif Conf.SQS:
|
||||
|
||||
@@ -35,9 +35,9 @@ class Disque(Broker):
|
||||
@staticmethod
|
||||
def get_connection(list_key=Conf.PREFIX):
|
||||
# randomize nodes
|
||||
random.shuffle(Conf.DISQUE)
|
||||
random.shuffle(Conf.DISQUE_NODES)
|
||||
# find one that works
|
||||
for node in Conf.DISQUE:
|
||||
for node in Conf.DISQUE_NODES:
|
||||
host, port = node.split(':')
|
||||
redis_client = redis.Redis(host, int(port))
|
||||
try:
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ class Conf(object):
|
||||
DJANGO_REDIS = conf.get('django_redis', None)
|
||||
|
||||
# Disque broker
|
||||
DISQUE = conf.get('disque', None)
|
||||
DISQUE_NODES = conf.get('disque_nodes', None)
|
||||
# Optional Authentication
|
||||
DISQUE_AUTH = conf.get('disque_auth', None)
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ def test_redis():
|
||||
@pytest.mark.skipif(not os.getenv('DISQUE', None),
|
||||
reason="No disque server configured")
|
||||
def test_disque():
|
||||
Conf.DISQUE = ['127.0.0.1:7711']
|
||||
Conf.DISQUE_NODES = ['127.0.0.1:7711']
|
||||
broker = get_broker(list_key='disque_test')
|
||||
assert broker.ping() is True
|
||||
broker.delete_queue()
|
||||
@@ -58,13 +58,13 @@ def test_disque():
|
||||
broker.acknowledge(task[0])
|
||||
sleep(1.5)
|
||||
assert broker.queue_size() == 0
|
||||
Conf.DISQUE = ['127.0.0.1:7712', '127.0.0.1:7713']
|
||||
Conf.DISQUE_NODES = ['127.0.0.1:7712', '127.0.0.1:7713']
|
||||
with pytest.raises(redis.exceptions.ConnectionError):
|
||||
broker.get_connection()
|
||||
broker.delete_queue()
|
||||
assert broker.queue_size() == 0
|
||||
# back to django-redis
|
||||
Conf.DISQUE = None
|
||||
Conf.DISQUE_NODES = None
|
||||
|
||||
|
||||
@pytest.mark.skipif(not os.getenv('AWS_ACCESS_KEY_ID'),
|
||||
@@ -120,14 +120,14 @@ def test_ironmq():
|
||||
assert broker.queue_size() == 1
|
||||
broker.dequeue()
|
||||
assert broker.queue_size() == 0
|
||||
sleep(1.5)
|
||||
sleep(2)
|
||||
assert broker.queue_size() == 1
|
||||
task = broker.dequeue()
|
||||
assert broker.queue_size() == 0
|
||||
broker.acknowledge(task[0])
|
||||
sleep(1.5)
|
||||
sleep(2)
|
||||
assert broker.queue_size() == 0
|
||||
broker.delete_queue()
|
||||
assert broker.queue_size() == 0
|
||||
# back to django-redis
|
||||
Conf.DISQUE = None
|
||||
Conf.IRONMQ = None
|
||||
|
||||
Reference in New Issue
Block a user