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.
  • 相关阅读:
    linux 从入门到跑路-目录结构的理解
    linux 从入门到跑路-ls,cp,mkdir命令练习
    linux 从入门到跑路-电源管理
    java 图形界面 Socket编程
    java 图形界面 mvc模式控制
    java 邮件
    java 图形界面
    java 文件的基本操作
    java基础算法题
    java 字符串
  • 原文地址:https://www.cnblogs.com/Michael-Scofields/p/13685081.html
Copyright © 2011-2022 走看看