mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-08 05:58:13 +08:00
moved auth to redis py
This commit is contained in:
@@ -5,7 +5,6 @@ from django_q.conf import Conf
|
|||||||
|
|
||||||
|
|
||||||
class Disque(Broker):
|
class Disque(Broker):
|
||||||
|
|
||||||
def enqueue(self, task):
|
def enqueue(self, task):
|
||||||
retry = Conf.RETRY if Conf.RETRY > 0 else '{} REPLICATE 1'.format(Conf.RETRY)
|
retry = Conf.RETRY if Conf.RETRY > 0 else '{} REPLICATE 1'.format(Conf.RETRY)
|
||||||
return self.connection.execute_command(
|
return self.connection.execute_command(
|
||||||
@@ -23,8 +22,6 @@ class Disque(Broker):
|
|||||||
return self.connection.execute_command('ACKJOB {}'.format(task_id))
|
return self.connection.execute_command('ACKJOB {}'.format(task_id))
|
||||||
|
|
||||||
def ping(self):
|
def ping(self):
|
||||||
if Conf.DISQUE_AUTH:
|
|
||||||
self.connection.execute_command('AUTH {}'.format(Conf.DISQUE_AUTH))
|
|
||||||
return self.connection.execute_command('HELLO')[0] > 0
|
return self.connection.execute_command('HELLO')[0] > 0
|
||||||
|
|
||||||
def delete(self, task_id):
|
def delete(self, task_id):
|
||||||
@@ -46,11 +43,12 @@ class Disque(Broker):
|
|||||||
# find one that works
|
# find one that works
|
||||||
for node in Conf.DISQUE_NODES:
|
for node in Conf.DISQUE_NODES:
|
||||||
host, port = node.split(':')
|
host, port = node.split(':')
|
||||||
redis_client = redis.Redis(host, int(port))
|
kwargs = {'host': host, 'port': port}
|
||||||
|
if Conf.DISQUE_AUTH:
|
||||||
|
kwargs['password'] = Conf.DISQUE_AUTH
|
||||||
|
redis_client = redis.Redis(**kwargs)
|
||||||
|
redis_client.decode_responses = True
|
||||||
try:
|
try:
|
||||||
if Conf.DISQUE_AUTH:
|
|
||||||
redis_client.execute_command('AUTH {}'.format(Conf.DISQUE_AUTH))
|
|
||||||
redis_client.decode_responses = True
|
|
||||||
redis_client.execute_command('HELLO')
|
redis_client.execute_command('HELLO')
|
||||||
return redis_client
|
return redis_client
|
||||||
except redis.exceptions.ConnectionError:
|
except redis.exceptions.ConnectionError:
|
||||||
|
|||||||
Reference in New Issue
Block a user