尽管异常被捕,但仍会打印回溯

时间:2017-11-01 02:43:44

标签: python python-requests traceback

有时,我将无法使用此GroupMe API wrapper收到发送/接收请求。我可以抓住Exception,虽然程序继续运行,但仍然会得到一个冗长的回溯。完全追溯:

could not recieve a response
Traceback (most recent call last):
  File "E:\Users\Sebastian\Anaconda3\lib\site-packages\requests\packages\urllib3\connection.py", line 137, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "E:\Users\Sebastian\Anaconda3\lib\site-packages\requests\packages\urllib3\util\connection.py", line 67, in create_connection
    for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
  File "E:\Users\Sebastian\Anaconda3\lib\socket.py", line 743, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\Users\Sebastian\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 559, in urlopen
    body=body, headers=headers)
  File "E:\Users\Sebastian\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
  File "E:\Users\Sebastian\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 784, in _validate_conn
    conn.connect()
  File "E:\Users\Sebastian\Anaconda3\lib\site-packages\requests\packages\urllib3\connection.py", line 217, in connect
    conn = self._new_conn()
  File "E:\Users\Sebastian\Anaconda3\lib\site-packages\requests\packages\urllib3\connection.py", line 146, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002CD65CF60F0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\Users\Sebastian\Anaconda3\lib\site-packages\requests\adapters.py", line 376, in send
    timeout=timeout
  File "E:\Users\Sebastian\Anaconda3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 609, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "E:\Users\Sebastian\Anaconda3\lib\site-packages\requests\packages\urllib3\util\retry.py", line 273, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.groupme.com', port=443): Max retries exceeded with url: /v3/chats?token=98d6c1109f660135d705089a21c58196 (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002CD65CF60F0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\Users\Sebastian\Anaconda3\lib\site-packages\groupy\session.py", line 25, in request
    response = super().request(*args, **kwargs)
  File "E:\Users\Sebastian\Anaconda3\lib\site-packages\requests\sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "E:\Users\Sebastian\Anaconda3\lib\site-packages\requests\sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "E:\Users\Sebastian\Anaconda3\lib\site-packages\requests\adapters.py", line 437, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.groupme.com', port=443): Max retries exceeded with url: /v3/chats?token=98d6c1109f660135d705089a21c58196 (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x000002CD65CF60F0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',))

我发现它特别有趣,它始于&#34;无法收到响应&#34;在Traceback之前(包括拼写错误),但我不能为我的生活找到那条线的位置。它当然不在我的代码中,也不在于groupy模块的代码。

1 个答案:

答案 0 :(得分:0)

不相信Github上的搜索功能

尽管在回购中搜索"recieve",但只出现了不同的情况。但是,问题发生在session.py,其中记录和引发了异常。