python socket reconnect after timeout code example Example: set timeout python socket socket.settimeout(1) # for 1 sec