|
@@ -1,6 +1,8 @@
|
|
|
"""
|
|
|
@author: luojunhui
|
|
|
"""
|
|
|
+import asyncio
|
|
|
+
|
|
|
from applications.static.config import db_article
|
|
|
from applications.schedule import search_videos
|
|
|
|
|
@@ -201,6 +203,27 @@ class ProcessDeal(object):
|
|
|
"""
|
|
|
await self.mysql_client.async_insert(sql=update_sql4)
|
|
|
|
|
|
+ async def process_task(self, params):
|
|
|
+ """
|
|
|
+ 异步执行
|
|
|
+ :param params:
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ content_id = params['content_id']
|
|
|
+ # 判断该文章是否已经生成了
|
|
|
+ history_trace_id = await self.get_history_contents(content_id)
|
|
|
+ if history_trace_id:
|
|
|
+ # 说明已经存在了结果, 将该条记录下的video_id拿出来
|
|
|
+ print("该文章已经成功请求")
|
|
|
+ await self.insert_history_contents_videos(history_trace_id, params)
|
|
|
+ else:
|
|
|
+ flag = await self.judge_content_processing(content_id)
|
|
|
+ if flag:
|
|
|
+ print("开始处理这条视频")
|
|
|
+ await self.start_process(params=params)
|
|
|
+ else:
|
|
|
+ print("该文章id正在处理中")
|
|
|
+
|
|
|
async def deal(self):
|
|
|
"""
|
|
|
处理
|
|
@@ -208,20 +231,7 @@ class ProcessDeal(object):
|
|
|
"""
|
|
|
task_list = await self.get_task()
|
|
|
if task_list:
|
|
|
- for params in task_list:
|
|
|
- content_id = params['content_id']
|
|
|
- # 判断该文章是否已经生成了
|
|
|
- history_trace_id = await self.get_history_contents(content_id)
|
|
|
- if history_trace_id:
|
|
|
- # 说明已经存在了结果, 将该条记录下的video_id拿出来
|
|
|
- print("该文章已经成功请求")
|
|
|
- await self.insert_history_contents_videos(history_trace_id, params)
|
|
|
- else:
|
|
|
- flag = await self.judge_content_processing(content_id)
|
|
|
- if flag:
|
|
|
- print("开始处理这条视频")
|
|
|
- await self.start_process(params=params)
|
|
|
- else:
|
|
|
- print("该文章id正在处理中")
|
|
|
+ tasks = [self.process_task(params) for params in task_list]
|
|
|
+ await asyncio.gather(*tasks)
|
|
|
else:
|
|
|
print("没有要处理的视频")
|