'commit'
This commit is contained in:
@@ -40,7 +40,7 @@ class JmImg2Video(JmCommon):
|
||||
|
||||
def main():
|
||||
try:
|
||||
# 玩法参考: https://www.volcengine.com/docs/85621/1544774
|
||||
# 参考: https://www.volcengine.com/docs/85621/1544774
|
||||
image_urls = [
|
||||
"https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/Backup/Text2Img.jpg"
|
||||
]
|
||||
@@ -55,41 +55,11 @@ def main():
|
||||
"""
|
||||
|
||||
mp4_file_name = "image2video.mp4"
|
||||
|
||||
# 添加重试逻辑,处理API并发限制错误
|
||||
submit_result = None
|
||||
submit_retry_count = 0
|
||||
max_submit_retries = 1000 # 最大重试次数
|
||||
submit_retry_interval = 3000 # 重试间隔(毫秒)
|
||||
|
||||
while submit_retry_count < max_submit_retries:
|
||||
try:
|
||||
submit_result = JmImg2Video.submit_image_to_video_task(image_urls, prompt)
|
||||
logger.info(f"提交结果: {submit_result}")
|
||||
|
||||
code = submit_result.get("code")
|
||||
if code == JmErrorCode.API_CONCURRENT_LIMIT[0]:
|
||||
logger.warning(f"API并发限制,等待{submit_retry_interval}毫秒后重试...")
|
||||
time.sleep(submit_retry_interval / 1000)
|
||||
submit_retry_count += 1
|
||||
continue
|
||||
elif not JmErrorCode.is_success(code):
|
||||
logger.error(f"提交任务失败: 错误码={code}, 错误信息={JmErrorCode.get_message_by_code(code)}")
|
||||
return
|
||||
|
||||
# 成功获取结果,跳出循环
|
||||
break
|
||||
except Exception as e:
|
||||
logger.error(f"提交任务异常: {str(e)}", exc_info=True)
|
||||
submit_retry_count += 1
|
||||
if submit_retry_count < max_submit_retries:
|
||||
logger.warning(f"等待{submit_retry_interval}毫秒后重试...")
|
||||
time.sleep(submit_retry_interval / 1000)
|
||||
else:
|
||||
raise # 达到最大重试次数,抛出异常
|
||||
|
||||
if submit_retry_count >= max_submit_retries:
|
||||
logger.error(f"提交任务失败,已达到最大重试次数: {max_submit_retries}")
|
||||
submit_result = JmImg2Video.submit_image_to_video_task(image_urls, prompt)
|
||||
logger.info(f"提交结果: {submit_result}")
|
||||
code = submit_result.get("code")
|
||||
if not JmErrorCode.is_success(code):
|
||||
logger.error(f"提交任务失败: 错误码={code}, 错误信息={JmErrorCode.get_message_by_code(code)}")
|
||||
return
|
||||
|
||||
# 获取任务ID
|
||||
|
Reference in New Issue
Block a user