equests.exceptions.ConnectionErr

2019-06-27  本文已影响0人  gz_tester

出现的问题

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='salesp.sunlands.wang', port=443): Max retries exceeded with url: /salesplatform-web-api/sales-users/_self (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f9e77ac5390>: Failed to establish a new connection: [Errno -2] Name or service not known',))

原因

使用url:超出了最大重试次数

解决方法

    def __init__(self):
        requests.adapters.DEFAULT_RETRIES = 5  # 增加重连次数
        self.s = requests.session()
        self.s.keep_alive = False  # 关闭多余连接

上一篇下一篇

猜你喜欢

热点阅读