Browse Source

fix kimi task

luojunhui 5 months ago
parent
commit
ee67be575b
1 changed files with 30 additions and 1 deletions
  1. 30 1
      tasks/newContentIdTask.py

+ 30 - 1
tasks/newContentIdTask.py

@@ -13,6 +13,7 @@ from applications.functions.common import shuffle_list
 from applications.functions.kimi import KimiServer
 from applications.spider import search_videos_from_web
 from applications.etl_function import *
+from applications.feishu import bot
 
 
 class NewContentIdTask(object):
@@ -26,6 +27,7 @@ class NewContentIdTask(object):
     TASK_PUBLISHED_STATUS = 4
     TASK_PROCESSING_STATUS = 101
     TASK_FAIL_STATUS = 99
+    KIMI_ILLEGAL_STATUS = 95
     ARTICLE_TEXT_TABLE_ERROR = 98
     TASK_MAX_PROCESS_TIMES = 3
 
@@ -676,6 +678,8 @@ class NewContentIdTask(object):
         # time.sleep(5) # 测试多个进程操作同一个 task 的等待时间
         kimi_result = await self.kimi_task(params)
         trace_id = params['trace_id']
+        process_times = params['process_times']
+        content_id = params['content']
         if kimi_result:
             # 等待 kimi 操作执行完成之后,开始执行 spider_task
             print("kimi success")
@@ -731,8 +735,33 @@ class NewContentIdTask(object):
             logging(
                 code="6001",
                 info="kimi 处理失败",
-                trace_id=params['trace_id']
+                trace_id=trace_id
             )
+            if process_times >= self.TASK_MAX_PROCESS_TIMES:
+                logging(
+                    code="6011",
+                    info="kimi处理次数达到上限, 放弃处理",
+                    trace_id=trace_id
+                )
+                update_sql = f"""
+                    UPDATE {self.article_match_video_table}
+                    SER content_status = %s
+                    WHERE content_id = %s;
+                """
+                affected_rows = await self.mysql_client.async_insert(
+                    sql=update_sql,
+                    params=(
+                        self.KIMI_ILLEGAL_STATUS,
+                        content_id
+                    )
+                )
+                bot(
+                    title="KIMI 处理失败",
+                    detail={
+                        "content_id": content_id,
+                        "affected_rows": affected_rows
+                    }
+                )
 
     async def process_task(self, params):
         """