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  阅读(20039)  评论(0编辑  收藏  举报