mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-08 07:18:12 +08:00
fixed crash with badly signed packages and added redis ping
This commit is contained in:
+17
-12
@@ -55,6 +55,11 @@ redis_client = redis.StrictRedis(**REDIS)
|
|||||||
|
|
||||||
class Cluster(object):
|
class Cluster(object):
|
||||||
def __init__(self, list_key=Q_LIST):
|
def __init__(self, list_key=Q_LIST):
|
||||||
|
try:
|
||||||
|
redis_client.ping()
|
||||||
|
except Exception as e:
|
||||||
|
logger.exception(e)
|
||||||
|
return
|
||||||
self.sentinel = None
|
self.sentinel = None
|
||||||
self.stop_event = None
|
self.stop_event = None
|
||||||
self.start_event = None
|
self.start_event = None
|
||||||
@@ -297,19 +302,19 @@ def worker(task_queue, done_queue):
|
|||||||
try:
|
try:
|
||||||
task = SignedPackage.loads(pack)
|
task = SignedPackage.loads(pack)
|
||||||
except (TypeError, signing.BadSignature) as e:
|
except (TypeError, signing.BadSignature) as e:
|
||||||
result = (e, False)
|
logger.error(e)
|
||||||
|
continue
|
||||||
# Get the function from the task
|
# Get the function from the task
|
||||||
if not result:
|
logger.info('{} processing [{}]'.format(name, task['name']))
|
||||||
logger.info('{} processing [{}]'.format(name, task['name']))
|
f = task['func']
|
||||||
f = task['func']
|
# if it's not an instance try to get it from the string
|
||||||
# if it's not an instance try to get it from the string
|
if not callable(task['func']):
|
||||||
if not callable(task['func']):
|
try:
|
||||||
try:
|
module, func = f.rsplit('.', 1)
|
||||||
module, func = f.rsplit('.', 1)
|
m = importlib.import_module(module)
|
||||||
m = importlib.import_module(module)
|
f = getattr(m, func)
|
||||||
f = getattr(m, func)
|
except (ValueError, ImportError, AttributeError) as e:
|
||||||
except (ValueError, ImportError, AttributeError) as e:
|
result = (e, False)
|
||||||
result = (e, False)
|
|
||||||
# We're still going
|
# We're still going
|
||||||
if not result:
|
if not result:
|
||||||
# execute the payload
|
# execute the payload
|
||||||
|
|||||||
Reference in New Issue
Block a user