diff --git a/django_q/brokers/__init__.py b/django_q/brokers/__init__.py index ce7f9a8..1de452b 100644 --- a/django_q/brokers/__init__.py +++ b/django_q/brokers/__init__.py @@ -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: diff --git a/django_q/brokers/disque.py b/django_q/brokers/disque.py index 94fb4f8..b274e1f 100644 --- a/django_q/brokers/disque.py +++ b/django_q/brokers/disque.py @@ -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: diff --git a/django_q/conf.py b/django_q/conf.py index 0e9c7b7..b01d1d0 100644 --- a/django_q/conf.py +++ b/django_q/conf.py @@ -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) diff --git a/django_q/tests/test_brokers.py b/django_q/tests/test_brokers.py index 84fc9be..b0bbfca 100644 --- a/django_q/tests/test_brokers.py +++ b/django_q/tests/test_brokers.py @@ -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