|
|
@@ -33,7 +33,7 @@ import asyncio
|
|
|
from fastapi import BackgroundTasks
|
|
|
import functools
|
|
|
import traceback
|
|
|
-
|
|
|
+import concurrent.futures
|
|
|
|
|
|
def log_exception_with_context(context_message=""):
|
|
|
"""装饰器:为函数添加异常日志上下文"""
|
|
|
@@ -679,6 +679,10 @@ async def handle_detail_background(
|
|
|
is_product_scene = params.is_product_scene # 上传第三方的店铺名称数组
|
|
|
is_upper_footer = params.is_upper_footer # 上传第三方的店铺名称数组
|
|
|
# 该数组表示是否需要后面的移动文件夹操作,减少重复抠图,提升抠图时间和速度
|
|
|
+ if online_stores:
|
|
|
+ """如果上传第三方,则需要强制生成详情页"""
|
|
|
+ params.is_detail = 1
|
|
|
+ is_detail = 1
|
|
|
try:
|
|
|
excel_path = params.excel_path.strip()
|
|
|
print("excel信息打印输出:",excel_path)
|
|
|
@@ -810,7 +814,6 @@ async def process_handle_detail(request: Request, params: HandlerDetail):
|
|
|
return_data_check_before_detail = await _process_model_images(
|
|
|
aigc_clazz, run_main, return_data_check_before_detail, upper_footer_params
|
|
|
)
|
|
|
-
|
|
|
# 处理详情页
|
|
|
if is_detail == 1:
|
|
|
handler_result_folder, handler_result= await _process_detail_pages(
|
|
|
@@ -1184,43 +1187,49 @@ async def _process_model_images(aigc_clazz, run_main, return_data_check_before_d
|
|
|
)
|
|
|
|
|
|
for goods_art_no in goods_dict.keys():
|
|
|
- upper_footer_finish_progress += 1
|
|
|
- upper_footer_progress = {
|
|
|
- "status": "正在处理",
|
|
|
- "goods_art_no": goods_art_no,
|
|
|
- "current": upper_footer_finish_progress,
|
|
|
- "total": upper_footer_total_progress,
|
|
|
- "error": upper_footer_error_progress
|
|
|
- }
|
|
|
-
|
|
|
- await sendAsyncMessage(
|
|
|
- msg="正在处理模特图",
|
|
|
- goods_arts=[goods_art_no],
|
|
|
- status="正在处理模特图",
|
|
|
- msg_type="upper_footer_progress",
|
|
|
- progress=upper_footer_progress
|
|
|
- )
|
|
|
-
|
|
|
- goods_art_dict_info = goods_dict[goods_art_no]
|
|
|
- first_goods_art_no_info = goods_art_dict_info.get("货号资料", [])[0]
|
|
|
- first_pics = first_goods_art_no_info.get("pics")
|
|
|
- gender = goods_art_dict_info.get("性别","女")
|
|
|
- model_id = man_id if "男" in gender else women_id
|
|
|
- ceshi_image_path = first_pics.get("侧视-抠图")
|
|
|
- save_root_path = ceshi_image_path.split("阴影图处理")[0]
|
|
|
- save_image_path = f"{save_root_path}模特图.jpg"
|
|
|
-
|
|
|
- if os.path.isfile(save_image_path):
|
|
|
- goods_art_dict_info["模特图"] = save_image_path
|
|
|
- new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
|
- continue
|
|
|
-
|
|
|
- shutil.copy(ceshi_image_path, save_image_path)
|
|
|
-
|
|
|
try:
|
|
|
- image_path = aigc_clazz.generateUpperShoes(
|
|
|
- save_image_path, model_id, save_image_path
|
|
|
+ upper_footer_finish_progress += 1
|
|
|
+ upper_footer_progress = {
|
|
|
+ "status": "正在处理",
|
|
|
+ "goods_art_no": goods_art_no,
|
|
|
+ "current": upper_footer_finish_progress,
|
|
|
+ "total": upper_footer_total_progress,
|
|
|
+ "error": upper_footer_error_progress
|
|
|
+ }
|
|
|
+
|
|
|
+ await sendAsyncMessage(
|
|
|
+ msg="正在处理模特图",
|
|
|
+ goods_arts=[goods_art_no],
|
|
|
+ status="正在处理模特图",
|
|
|
+ msg_type="upper_footer_progress",
|
|
|
+ progress=upper_footer_progress
|
|
|
)
|
|
|
+ goods_art_dict_info = goods_dict[goods_art_no]
|
|
|
+ first_goods_art_no_info = goods_art_dict_info.get("货号资料", [])[0]
|
|
|
+ first_pics = first_goods_art_no_info.get("pics")
|
|
|
+ gender = goods_art_dict_info.get("性别","女")
|
|
|
+ model_id = man_id if "男" in gender else women_id
|
|
|
+ ceshi_image_path = first_pics.get("侧视-抠图")
|
|
|
+ save_root_path = ceshi_image_path.split("阴影图处理")[0]
|
|
|
+ save_image_path = f"{save_root_path}模特图.jpg"
|
|
|
+
|
|
|
+ if os.path.isfile(save_image_path):
|
|
|
+ goods_art_dict_info["模特图"] = save_image_path
|
|
|
+ new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
|
+ continue
|
|
|
+
|
|
|
+ shutil.copy(ceshi_image_path, save_image_path)
|
|
|
+
|
|
|
+ # 添加超时控制
|
|
|
+ with concurrent.futures.ThreadPoolExecutor() as executor:
|
|
|
+ future = executor.submit(
|
|
|
+ aigc_clazz.generateUpperShoes,
|
|
|
+ save_image_path,
|
|
|
+ model_id,
|
|
|
+ save_image_path
|
|
|
+ )
|
|
|
+ # 设置70秒超时
|
|
|
+ image_path = future.result(timeout=70)
|
|
|
|
|
|
goods_art_dict_info["模特图"] = image_path
|
|
|
new_goods_dict[goods_art_no] = goods_art_dict_info
|
|
|
@@ -1241,7 +1250,7 @@ async def _process_model_images(aigc_clazz, run_main, return_data_check_before_d
|
|
|
progress=upper_footer_progress
|
|
|
)
|
|
|
|
|
|
- except Exception as e:
|
|
|
+ except (concurrent.futures.TimeoutError, Exception) as e:
|
|
|
os.remove(save_image_path)
|
|
|
upper_footer_error_progress += 1
|
|
|
|