feat: 429时等待一会

This commit is contained in:
caoqianming 2026-01-29 10:38:01 +08:00
parent d393e37842
commit ae298d0e6d
1 changed files with 4 additions and 0 deletions

View File

@ -11,6 +11,7 @@ from lxml import etree
from celery import current_app
from datetime import datetime
import random
import time
config.email = "caoqianming@foxmail.com"
config.max_retries = 0
@ -361,6 +362,9 @@ def save_pdf_from_openalex(paper:Paper):
paper.fetch_status = "fulltext_ready"
paper.save(update_fields=["has_fulltext", "has_fulltext_pdf", "fetch_status", "update_time"])
return "success"
elif res.status_code == 429:
time.sleep(random.randint(1, 10))
return save_pdf_from_openalex(paper)
# https://sci.bban.top/pdf/10.1016/j.conbuildmat.2020.121016.pdf?download=true