Llevo muy poquito con python y hasta el momento no me había encontrado con un error en cadena, siempre errores puntuales y localizados. 

El caso es que no sé cómo tratar esto, desconozco cómo realizar la traza de dónde empieza el error para ver a partir de ahí el motivo por el que se producen el resto de los errores.

Os dejo el error a ver si me podéis dar alguna pistilla

    Traceback (most recent call last):
      File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 160, in _new_conn
        (self._dns_host, self.port), self.timeout, **extra_kw
      File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 84, in create_connection
        raise err
      File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 74, in create_connection
        sock.connect(sa)
    socket.timeout: timed out
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 677, in urlopen
        chunked=chunked,
      File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 381, in _make_request
        self._validate_conn(conn)
      File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn
        conn.connect()
      File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 309, in connect
        conn = self._new_conn()
      File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 167, in _new_conn
        % (self.host, self.timeout),
    urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0xb56581d0>, 'Connection to api.binance.com timed out. (connect timeout=10)')
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
        timeout=timeout
      File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 727, in urlopen
        method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
      File "/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py", line 439, in increment
        raise MaxRetryError(_pool, url, error or ResponseError(cause))
    urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.binance.com', port=443): Max retries exceeded with url: /api/v1/ping (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0xb56581d0>, 'Connection to api.binance.com timed out. (connect timeout=10)'))
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "test.py", line 2, in <module>
        import core, telegram, math, os, binance
      File "/home/pi/Desktop/compartido/python/binance/the2/v2/core.py", line 7, in <module>
        client = Client(api_key = "xxxxxxxxxxxxxxx", api_secret = "yyyyyyyyyyyyyy")
      File "/usr/local/lib/python3.6/site-packages/binance/client.py", line 105, in __init__
        self.ping()
      File "/usr/local/lib/python3.6/site-packages/binance/client.py", line 393, in ping
        return self._get('ping')
      File "/usr/local/lib/python3.6/site-packages/binance/client.py", line 237, in _get
        return self._request_api('get', path, signed, version, **kwargs)
      File "/usr/local/lib/python3.6/site-packages/binance/client.py", line 202, in _request_api
        return self._request(method, uri, signed, **kwargs)
      File "/usr/local/lib/python3.6/site-packages/binance/client.py", line 196, in _request
        self.response = getattr(self.session, method)(uri, **kwargs)
      File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 543, in get
        return self.request('GET', url, **kwargs)
      File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 530, in request
        resp = self.send(prep, **send_kwargs)
      File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 643, in send
        r = adapter.send(request, **kwargs)
      File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 504, in send
        raise ConnectTimeout(e, request=request)
    requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='api.binance.com', port=443): Max retries exceeded with url: /api/v1/ping (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0xb56581d0>, 'Connection to api.binance.com timed out. (connect timeout=10)'))

Lo que yo pienso es algo como esto:
Socket.timeout es el primer error, y se produce en connection.py, linea 74 etc...
Esto provoca fallo en urllib3.connection.HTTPSConnection por el mismo error, timeout 10 segs
Esto además arrastra el problema hasta HTTPSConnectionPool(host='api.binance.com', port=443), en este caso ya por máximos intentos de conexión superados

Si estoy en lo cierto... lo que no sabría es cómo evitar que el programa se detenga cuando sucede el timeout. Lo bueno sería que si llega a darse ese timeout, que lo ignore y siga corriendo hasta que se vuelva a evaluar, o si no, que haga un segundo intento de conexión...

------UPDATE 08/12/2020

Añado el fragmento de código que pienso que puede estar generando PARTE del problema



    def credentials():
        global client
        #cesar@nexostudio
        client = Client(api_key = "xxxxxx", api_secret = "yyyyyy")
        
    
    
    
    try:
        credentials()
    except:
        Pass
 

Si yo estoy equivocada... intenta hacer la función y si no lo logra, sigue "Pass". Este código se volverá a ejecutar en sucesivas iteraciones dentro de un while en otra parte del código