merkwürdiges Problem, aber ich komme einfach nicht dahinter, wahrscheinlich ist die Lösung trivial (Python3.3.2 auf Linux), ich hänge nur im Moment vollkommen im Schacht.
Folgendes Code Snippet:
Code: Alles auswählen
while True:
try:
devList = lnetatmo.DeviceList(authorization)
break
except:
print ("Netatmo server did not respond, will retry in 60 seconds")
time.sleep(60)
Das Prinzip sollte ganz einfach sein: Server antwortet nicht, keine Netzanbindung etc. (deshalb keine qualifizierte Exception Abfrage): 60 Sekunden warten, dann noch mal probieren.
Wenn ich nun den Netzstecker ziehe um das Coding zu testen, würde ich erwarten, dass der Programmablauf genau in die Exception springt, tut er aber nicht:
und ich bin wieder auf der Konsole, ohne das die print Anweisung ausgeführt wird.Traceback (most recent call last):
File "/usr/lib64/python3.3/urllib/request.py", line 1248, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "/usr/lib64/python3.3/http/client.py", line 1061, in request
self._send_request(method, url, body, headers)
File "/usr/lib64/python3.3/http/client.py", line 1099, in _send_request
self.endheaders(body)
File "/usr/lib64/python3.3/http/client.py", line 1057, in endheaders
self._send_output(message_body)
File "/usr/lib64/python3.3/http/client.py", line 902, in _send_output
self.send(msg)
File "/usr/lib64/python3.3/http/client.py", line 840, in send
self.connect()
File "/usr/lib64/python3.3/http/client.py", line 1194, in connect
self.timeout, self.source_address)
File "/usr/lib64/python3.3/socket.py", line 417, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "pyqt_netatmo.py", line 24, in <module>
authorization = lnetatmo.ClientAuth()
File "/home/ich/python3/pyqt_netatmo/lnetatmo.py", line 62, in __init__
resp = postRequest(_AUTH_REQ, postParams)
File "/home/ich/python3/pyqt_netatmo/lnetatmo.py", line 242, in postRequest
resp = urllib.request.urlopen(req, params).readall().decode("utf-8")
File "/usr/lib64/python3.3/urllib/request.py", line 156, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib64/python3.3/urllib/request.py", line 469, in open
response = self._open(req, data)
File "/usr/lib64/python3.3/urllib/request.py", line 487, in _open
'_open', req)
File "/usr/lib64/python3.3/urllib/request.py", line 447, in _call_chain
result = func(*args)
File "/usr/lib64/python3.3/urllib/request.py", line 1283, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/usr/lib64/python3.3/urllib/request.py", line 1251, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>
Wie kann das sein?