python: reconnect nicely on connection timeout