Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Timeout exceptions not handled properly #47

Open
Labels
@kuchel77

Description

When using the example script, and putting in the details for my NAS which has been turned off, I am getting the following messages as the timeout exceptions haven't be properly handled in the code.

This also then impacts on Home Assistant using this, and this is filling the logs as well rather than a simple offline message.

Creating Valid API
=== Information ===
DEBUG: Request params: {'api': 'SYNO.API.Info', 'version': 1, 'method': 'query'}
Traceback (most recent call last):
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connection.py", line 156, in _new_conn
 conn = connection.create_connection(
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/util/connection.py", line 84, in create_connection
 raise err
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/util/connection.py", line 74, in create_connection
 sock.connect(sa)
TimeoutError: [Errno 60] Operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 665, in urlopen
 httplib_response = self._make_request(
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 387, in _make_request
 conn.request(method, url, **httplib_request_kw)
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1230, in request
 self._send_request(method, url, body, headers, encode_chunked)
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1276, in _send_request
 self.endheaders(body, encode_chunked=encode_chunked)
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1225, in endheaders
 self._send_output(message_body, encode_chunked=encode_chunked)
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1004, in _send_output
 self.send(msg)
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 944, in send
 self.connect()
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connection.py", line 184, in connect
 conn = self._new_conn()
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connection.py", line 168, in _new_conn
 raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fe1e84aa100>: Failed to establish a new connection: [Errno 60] Operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
 resp = conn.urlopen(
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/connectionpool.py", line 719, in urlopen
 retries = retries.increment(
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/urllib3/util/retry.py", line 436, in increment
 raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.0.152', port=5000): Max retries exceeded with url: /webapi/query.cgi?api=SYNO.API.Info&version=1&method=query (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fe1e84aa100>: Failed to establish a new connection: [Errno 60] Operation timed out'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
 File "/Users/t08640554/Documents/python-synology/synology_dsm/synology_dsm.py", line 240, in _execute_request
 resp = self._session.get(url, **kwargs)
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/requests/sessions.py", line 543, in get
 return self.request('GET', url, **kwargs)
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
 resp = self.send(prep, **send_kwargs)
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
 r = adapter.send(request, **kwargs)
 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
 raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.0.152', port=5000): Max retries exceeded with url: /webapi/query.cgi?api=SYNO.API.Info&version=1&method=query (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fe1e84aa100>: Failed to establish a new connection: [Errno 60] Operation timed out'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
 File "test.py", line 7, in <module>
 print("Model: " + str(api.information.model))
 File "/Users/t08640554/Documents/python-synology/synology_dsm/synology_dsm.py", line 280, in information
 data = self.get(SynoDSMInformation.API_KEY, "getinfo")
 File "/Users/t08640554/Documents/python-synology/synology_dsm/synology_dsm.py", line 173, in get
 return self._request("GET", api, method, params, **kwargs)
 File "/Users/t08640554/Documents/python-synology/synology_dsm/synology_dsm.py", line 187, in _request
 self.discover_apis()
 File "/Users/t08640554/Documents/python-synology/synology_dsm/synology_dsm.py", line 108, in discover_apis
 self._apis = self.get(self.API_INFO, "query")["data"]
 File "/Users/t08640554/Documents/python-synology/synology_dsm/synology_dsm.py", line 173, in get
 return self._request("GET", api, method, params, **kwargs)
 File "/Users/t08640554/Documents/python-synology/synology_dsm/synology_dsm.py", line 217, in _request
 response = self._execute_request(request_method, url, params=params, **kwargs)
 File "/Users/t08640554/Documents/python-synology/synology_dsm/synology_dsm.py", line 256, in _execute_request
 raise SynologyDSMRequestException(exp)
synology_dsm.exceptions.SynologyDSMRequestException: ConnectionError = <urllib3.connection.HTTPConnection object at 0x7fe1e84aa100>: Failed to establish a new connection: [Errno 60] Operation timed out

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /