Created
November 8, 2016 08:13
-
-
Save bobthemighty/e3c7133bbd52f0bd6a1d4ff217ae7a01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def doSomethingThatMightFail(): | |
attempts = 0 | |
success = False | |
retry = True | |
while retry and not success: | |
success = call_the_service() | |
if attempts ++ > MAX_ATTEMPTS: | |
retry false | |
else: | |
jitter = random.next(0, 200) // random jitter between 0 and 200 ms. | |
wait_time = 100 * (attempts ** 2) // 100 ms, then 400 ms, then 900 ms, then 1600 ms.... | |
wait_for( jitter + wait_time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment