|
@@ -1,9 +1,9 @@
|
|
from common import Feishu, Material
|
|
from common import Feishu, Material
|
|
from common.sql_help import sqlHelp
|
|
from common.sql_help import sqlHelp
|
|
from video_agc.agc_video_method import AgcVidoe
|
|
from video_agc.agc_video_method import AgcVidoe
|
|
|
|
+import concurrent.futures
|
|
|
|
|
|
import schedule
|
|
import schedule
|
|
-import threading
|
|
|
|
import time
|
|
import time
|
|
|
|
|
|
|
|
|
|
@@ -11,7 +11,7 @@ import time
|
|
returned_usernames_today = set()
|
|
returned_usernames_today = set()
|
|
def video_start(user_data):
|
|
def video_start(user_data):
|
|
global returned_usernames_today
|
|
global returned_usernames_today
|
|
- user_data_mark = user_data[0]["mark"]
|
|
|
|
|
|
+ user_data_mark = user_data["mark"]
|
|
# 开始准备执行生成视频脚本
|
|
# 开始准备执行生成视频脚本
|
|
if user_data_mark is not None and user_data_mark in returned_usernames_today:
|
|
if user_data_mark is not None and user_data_mark in returned_usernames_today:
|
|
print(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。")
|
|
print(f"视频脚本参数中的用户名 {user_data_mark} 今天已经返回过,不再启动线程。")
|
|
@@ -19,22 +19,23 @@ def video_start(user_data):
|
|
elif user_data_mark is not None:
|
|
elif user_data_mark is not None:
|
|
print(f"视频脚本参数{user_data}")
|
|
print(f"视频脚本参数{user_data}")
|
|
mark = AgcVidoe.video_stitching(user_data)
|
|
mark = AgcVidoe.video_stitching(user_data)
|
|
- returned_usernames_today.add(mark)
|
|
|
|
|
|
+ if mark:
|
|
|
|
+ returned_usernames_today.add(mark)
|
|
|
|
|
|
|
|
|
|
# 定义定时任务
|
|
# 定义定时任务
|
|
def video_task():
|
|
def video_task():
|
|
print("开始执行生成视频脚.")
|
|
print("开始执行生成视频脚.")
|
|
data = Material.feishu_list()
|
|
data = Material.feishu_list()
|
|
- threads = []
|
|
|
|
- for _, user_data in data.iterrows():
|
|
|
|
- thread = threading.Thread(target=video_start, args=(user_data,))
|
|
|
|
- threads.append(thread)
|
|
|
|
- thread.start()
|
|
|
|
- for thread in threads:
|
|
|
|
- thread.join()
|
|
|
|
|
|
+ # 创建一个线程池
|
|
|
|
+ with concurrent.futures.ThreadPoolExecutor() as executor:
|
|
|
|
+ futures = [executor.submit(video_start, user_data) for user_data in data]
|
|
|
|
+ # 等待所有任务执行完成
|
|
|
|
+ for future in concurrent.futures.as_completed(futures):
|
|
|
|
+ # 获取每个任务的执行结果
|
|
|
|
+ result = future.result()
|
|
|
|
+ print("处理结果:", result)
|
|
print("执行生成视频脚结束")
|
|
print("执行生成视频脚结束")
|
|
-
|
|
|
|
schedule.every(10).minutes.do(video_task)
|
|
schedule.every(10).minutes.do(video_task)
|
|
|
|
|
|
# 每天0点清空集合
|
|
# 每天0点清空集合
|