移除 NanoBananaPro 单张模式的自动重试逻辑
This commit is contained in:
@@ -686,11 +686,7 @@ class NanoBananaPro:
|
|||||||
else:
|
else:
|
||||||
# 单提示词模式
|
# 单提示词模式
|
||||||
if 生图数量 == 1:
|
if 生图数量 == 1:
|
||||||
# 单张:同步生成,自动重试(429/503/504)
|
# 单张:同步生成
|
||||||
_RETRY_CODES = ("429", "503", "504")
|
|
||||||
_MAX_RETRIES = 5
|
|
||||||
for _attempt in range(1, _MAX_RETRIES + 1):
|
|
||||||
try:
|
|
||||||
generated_images = self.client.generate_sync(
|
generated_images = self.client.generate_sync(
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
model=模型,
|
model=模型,
|
||||||
@@ -705,19 +701,6 @@ class NanoBananaPro:
|
|||||||
enable_image_search=enable_image_search,
|
enable_image_search=enable_image_search,
|
||||||
image_format=image_format,
|
image_format=image_format,
|
||||||
)
|
)
|
||||||
break
|
|
||||||
except RuntimeError as e:
|
|
||||||
error_msg = str(e)
|
|
||||||
if any(code in error_msg for code in _RETRY_CODES) and _attempt < _MAX_RETRIES:
|
|
||||||
_wait = 2 ** _attempt
|
|
||||||
print(f"{'=' * 60}")
|
|
||||||
print(f"⚠️ Nano Banana Pro 自动重试 [{_attempt}/{_MAX_RETRIES - 1}]")
|
|
||||||
print(f" 原因:{error_msg}")
|
|
||||||
print(f" 等待 {_wait}s 后重试...")
|
|
||||||
print(f"{'=' * 60}")
|
|
||||||
time.sleep(_wait)
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
else:
|
else:
|
||||||
# 多张:异步并发,内存输出
|
# 多张:异步并发,内存输出
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user