Answer the question
In order to leave comments, you need to log in
How can I restart the script in case of a connection error with the server?
Hello, I have a script like this:
ws = create_connection("ws://153.12.13.51/ws/")
ws.send("action=auth&login=Terminal13&passw=TTT")
print ws.recv()
ws.send("action=code_in&code=0)
print ws.recv()
ws.send("action=game&id=3000&verbose=1")
print ws.recv()
ws.send("some text")
print ws.recv()
Answer the question
In order to leave comments, you need to log in
How to make script restart automatically on timeout errors in python?
Wrap it in a loop, exiting from which will be carried out only with a successful connection. Install exception hooks that will start the loop from the beginning.
who knows, I use such things on a server, no one has complained yet :)
while True:
in_msg = self._socket.receive()
if in_msg is None:
break
continue
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question