fix(resm): openalex PDF 下载请求补 timeout

save_pdf_from_openalex 的 content.openalex.org 请求此前未设超时,
单次请求挂死会拖过 120s alive 心跳, 触发 ensure_fetch_running 重复点火、
叠加并发链狂打 API。补 timeout=(3,15) 与 elsevier 各处一致,
超时由外层 RequestException 捕获并正常收尾。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
caoqianming 2026-06-23 15:39:16 +08:00
parent 75d02814c6
commit 1e54070d6d
1 changed files with 2 additions and 1 deletions

View File

@ -839,7 +839,8 @@ def save_pdf_from_openalex(paper:Paper):
res = requests.get(url=f"https://content.openalex.org/works/{paper.openalex_id}.pdf", res = requests.get(url=f"https://content.openalex.org/works/{paper.openalex_id}.pdf",
params={ params={
"api_key": OPENALEX_KEY "api_key": OPENALEX_KEY
}) },
timeout=(3, 15))
except requests.RequestException as e: except requests.RequestException as e:
return f"openalex_pdf_error: {str(e)}" return f"openalex_pdf_error: {str(e)}"
if res.status_code == 200: if res.status_code == 200: