|
@@ -27,14 +27,14 @@ class RedisQueue:
|
|
keys = sorted(keys, key=lambda x: x.split('-')[-1], reverse=True)
|
|
keys = sorted(keys, key=lambda x: x.split('-')[-1], reverse=True)
|
|
return keys
|
|
return keys
|
|
|
|
|
|
- def push_task(self, key, tasks, level=1, allow_output_log=False):
|
|
|
|
|
|
+ def push_task(self, key, tasks, level=1, disable_debug_log=True):
|
|
"""
|
|
"""
|
|
双端队列,左边推进任务
|
|
双端队列,左边推进任务
|
|
|
|
|
|
:param key: 键名称
|
|
:param key: 键名称
|
|
:param tasks: 任务列表
|
|
:param tasks: 任务列表
|
|
:param level: 优先级(int类型),数值越大优先级越高,默认1
|
|
:param level: 优先级(int类型),数值越大优先级越高,默认1
|
|
- :param allow_output_log: 允许输出日志
|
|
|
|
|
|
+ :param disable_debug_log: 调试日志
|
|
:return: 任务队列任务数量
|
|
:return: 任务队列任务数量
|
|
"""
|
|
"""
|
|
# 重新定义优先队列的key
|
|
# 重新定义优先队列的key
|
|
@@ -42,7 +42,7 @@ class RedisQueue:
|
|
|
|
|
|
# 序列化任务参数
|
|
# 序列化任务参数
|
|
tasks = [json.dumps(t, default=lambda obj: obj.__dict__['data']) for t in tasks]
|
|
tasks = [json.dumps(t, default=lambda obj: obj.__dict__['data']) for t in tasks]
|
|
- if allow_output_log:
|
|
|
|
|
|
+ if not disable_debug_log:
|
|
logger.debug(f'RedisQueue info > the number of push tasks: {len(tasks)}')
|
|
logger.debug(f'RedisQueue info > the number of push tasks: {len(tasks)}')
|
|
|
|
|
|
if not tasks:
|
|
if not tasks:
|
|
@@ -82,17 +82,17 @@ class RedisQueue:
|
|
pass
|
|
pass
|
|
return results
|
|
return results
|
|
|
|
|
|
- def push_task_by_key(self, key, tasks, allow_output_log=False):
|
|
|
|
|
|
+ def push_task_by_key(self, key, tasks, disable_debug_log=True):
|
|
"""
|
|
"""
|
|
通过键名称从左边推进任务
|
|
通过键名称从左边推进任务
|
|
|
|
|
|
:param key: 键名称
|
|
:param key: 键名称
|
|
:param tasks: 推送的任务
|
|
:param tasks: 推送的任务
|
|
- :param allow_output_log: 允许输出日志
|
|
|
|
|
|
+ :param disable_debug_log: 调试日志
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
tasks = [json.dumps(t, default=lambda obj: obj.__dict__['data']) for t in tasks]
|
|
tasks = [json.dumps(t, default=lambda obj: obj.__dict__['data']) for t in tasks]
|
|
- if allow_output_log:
|
|
|
|
|
|
+ if not disable_debug_log:
|
|
logger.debug(f'RedisQueue info > the number of push tasks: {len(tasks)}')
|
|
logger.debug(f'RedisQueue info > the number of push tasks: {len(tasks)}')
|
|
if not tasks:
|
|
if not tasks:
|
|
return self.redis.llen(key)
|
|
return self.redis.llen(key)
|