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.
  • 相关阅读:
    POJ 1315 Don't Get Rooked
    POJ 2051 Argus
    POJ 1942 Paths on a Grid
    POJ 2151 Check the difficulty of problems
    POJ 3349 Snowflake Snow Snowflakes
    POJ 1753 Flip Game
    POJ 2392 Space Elevator
    POJ 2385 Apple Catching
    POJ 2356 Find a multiple
    POJ 2355 Railway tickets
  • 原文地址:https://www.cnblogs.com/Michael-Scofields/p/13685081.html
Copyright © 2011-2022 走看看