添加总重试次数限制

This commit is contained in:
xunbu
2025-06-04 10:15:07 +08:00
parent 22bda5b27d
commit 191b9d8343
4 changed files with 40 additions and 14 deletions

View File

@@ -135,11 +135,11 @@ async def _perform_translation(params: Dict[str, Any], file_contents: bytes, ori
md_content = ft.export_to_markdown()
try:
await httpx_client.head("https://cdn.bootcdn.net/ajax/libs/KaTeX/0.16.9/contrib/auto-render.min.js", timeout=3)
await httpx_client.head("https://s4.zstatic.net/ajax/libs/KaTeX/0.16.9/contrib/auto-render.min.js", timeout=3)
html_content = ft.export_to_html(title=current_state["original_filename_stem"], cdn=True)
except (httpx.TimeoutException, httpx.RequestError) as e:
print(f"连接cdn.bootcdn.net失败错误信息{e}")
translater_logger.info("无法连接cdn.bootcdn.net使用本地js进行pdf渲染")
translater_logger.info(f"连接s4.zstatic.net失败错误信息{e}")
translater_logger.info("使用本地js进行pdf渲染")
html_content = ft.export_to_html(title=current_state["original_filename_stem"], cdn=False)
end_time = time.time()
duration = end_time - current_state["task_start_time"]