So I want to make a code where the program tries to connect to something every minute:
while True:
try:
s.connect((HOST, PORT))
except:
time.sleep(60)
else:
break
So that it tries to connect, if there is an error it will wait and try again and if there is no error it will break the while-loop and continue with the code but I still get an error that it was not able to connect if i run the code:
Traceback (most recent call last):
File "***.py", line 40, in <module>
s.connect((HOST, PORT))
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused
Aucun commentaire:
Enregistrer un commentaire