Instead of just sleeping all the time, catch the exceptions or http status codes and then sleep.