requests优雅的重试

Lan
Lan
2023-10-26 / 0 评论 / 31 阅读 / 正在检测是否收录...
import requests
from requests.adapters import HTTPAdapter, Retry

session = requests.Session()
retries = Retry(total=3, backoff_factor=1)
session.mount('http://', HTTPAdapter(max_retries=retries))
session.mount('https://', HTTPAdapter(max_retries=retries))

使用requests自带的adapters

0

评论 (0)

取消