Python异常总结

异常总结

Max retries exceeded with url

HTTPConnectionPool(host='dds.cr.usgs.gov', port=80): Max retries exceeded with url: /ltaauth//sno18/ops/l1/2016/138/037/LC81380372016038LGN00.tar.gz?id=stfb9e0bgrpmc4j9lcg45ikrj1&iid=LC81380372016038LGN00&did=227966479&ver=production (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 65] No route to host',))
  • 异常原因:
    http/https连接太多没有关闭导致。
  • 解决方案
    • 增加重试连接次数。
      python
      requests.adapters.DEFAULT_RETRIES = 5
    • 关闭多余连接
      python
      s = requests.session()
      s.keep_alive = False

你可能感兴趣的:(Python)