zoukankan      html  css  js  c++  java
  • 【参考】Python Error Note

    # Error:Failed to establish a new connection: [Errno 61] Connection refused

    Log:HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /search/repositories?q=CVE-2020&sort=updated (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ff08d7dfd30>: Failed to establish a new connection: [Errno 61] Connection refused',))

    Reason:http连接太多没有关闭导致

    Plan:

    1、增加重试连接次数

    import requests
    requests.adapters.DEFAULT_RETRIES = 5

    2、关闭多余的连接

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

    3、升级requests

    pip install --upgrade requests

     4、To overcome this issue (not so much an issue as it is misleading debug trace) you should catch connection related exceptions like so:

    try:
        page1 = requests.get(ap)
    except requests.exceptions.ConnectionError:
        r.status_code = "Connection refused"

    Another way to overcome this problem is if you use enough time gap to send requests to server this can be achieved by sleep(timeinsec) function in python (don't forget to import sleep)

    --------------------------------------------
    Chances are for those who are prepared.
  • 相关阅读:
    最大子串和
    [USACO1.5]数字金字塔 Number Triangles
    数字金字塔
    台阶问题
    取余运算
    数列分段pascal程序
    Java 集合-Collection接口和迭代器的实现
    Java 集合-集合介绍
    Java IO流-File类
    Git学习记录
  • 原文地址:https://www.cnblogs.com/Michael-Scofields/p/13685081.html
Copyright © 2011-2022 走看看