|
@@ -8,17 +8,22 @@ max_workers = 6
|
|
|
|
|
|
def video_ai_task_start():
|
|
|
with ThreadPoolExecutor( max_workers=max_workers) as executor:
|
|
|
+ redis_task_list = ['task:video_ai_top', 'task:video_ai_recommend']
|
|
|
+ # 任务索引
|
|
|
+ task_index = 0
|
|
|
while True:
|
|
|
- redis_task_list = ['task:video_ai_top', 'task:video_ai_recommend']
|
|
|
try:
|
|
|
- futures = []
|
|
|
- for redis_task in redis_task_list:
|
|
|
- futures.append(executor.submit( process_video_ai, redis_task))
|
|
|
- time.sleep(1) # 每秒提交一个任务
|
|
|
- wait( futures ) # 等待所有任务完成
|
|
|
+ # 提交任务
|
|
|
+ executor.submit( process_video_ai, redis_task_list[task_index] )
|
|
|
+
|
|
|
+ task_index += 1
|
|
|
+ if task_index >= len( redis_task_list ):
|
|
|
+ task_index = 0 # 重置索引
|
|
|
+
|
|
|
+ time.sleep( 1 ) # 每秒提交一个任务
|
|
|
except Exception as e:
|
|
|
- print(f"异常信息{e}")
|
|
|
- time.sleep(1)
|
|
|
+ print( f"异常信息: {e}" )
|
|
|
+ time.sleep( 3 ) # 等待3秒后重试
|
|
|
continue
|
|
|
|
|
|
def process_video_ai(redis_task):
|