Search code examples
pythonpython-requeststraceback

Traceback is Printed Despite Exception Being Caught


Occasionally, I will fail to get a send/receive a request with this GroupMe API wrapper. I can catch the Exception raised, but I still get a lengthy traceback, despite the program continuing to run. Full traceback:

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',))

I find it particularly interesting that it starts with "could not recieve a response" (misspelling included) before the Traceback, but I cannot for the life of me find where that line is. It certainly isn't in my code, nor the code of the groupy module.


Solution

  • Don't trust the search feature on Github

    Despite searching "recieve" on the repo, only a different occurrence of it showed up. However, the problem was in session.py, where an Exception was both logged and raised.