解决“Max retries exceeded with url”问题

用requests的post方法获取内容时,遇到以下报错:

ConnectionError: HTTPConnectionPool(host=‘xxx.xx.xxx.xxx’, port=xxxx): Max retries exceeded with url: /api/v1/login/ (Caused by NewConnectionError(’: Failed to establish a new connection: [Errno 111] Connection refused’,))
提示说请求太频繁,查阅资料有方法说用sleep,但是并没有解决我遇到的这种问题,最后解决办法是:
关闭多余的连接

s = requests.session()
s.keep_alive = False

你可能感兴趣的:(工作杂项)