随笔-149  评论-58  文章-0 

python requests 配置超时及重试次数

import requests
from requests.adapters import HTTPAdapter

s = requests.Session()
s.mount('http://', HTTPAdapter(max_retries=3))
s.mount('https://', HTTPAdapter(max_retries=3))

s.get('http://example.com', timeout=1)

 

posted on 2015-12-24 12:05 eshizhan 阅读(...) 评论(...) 编辑 收藏