Simplify loop and fix off-by-one error with unneeded sleep
When this loop is executed, its counter goes from max_attempts, let's say 3 to 0 (2, 1, 0). Before each try of resending message were entered sleep, to not send all retries in almost same moment. So expected behavior was: - first try (2 attempts left, previously were 3) - failed, so sleep... - second try (1 attempts left, previously were 2) - failed, so sleep... - third try (0 attempts left, previously were 1) - failed, but there is no more attempts left (previously was 1), so immediately raise exception, without sleep. Previous code version, because of bug, unnecessary waited before raising exception.