移除 NanoBananaPro 单张模式的自动重试逻辑

This commit is contained in:
o1key
2026-04-27 12:25:58 +08:00
parent c646b0d1d7
commit 85f9228220
+1 -18
View File
@@ -686,11 +686,7 @@ class NanoBananaPro:
else:
# 单提示词模式
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(
prompt=prompt,
model=模型,
@@ -705,19 +701,6 @@ class NanoBananaPro:
enable_image_search=enable_image_search,
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:
# 多张:异步并发,内存输出