Last active
July 12, 2017 10:42
-
-
Save dsaiztc/d438ae50c71cd504fa6a68503ff6178d to your computer and use it in GitHub Desktop.
Exponential backoff.
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
from time import sleep | |
def try(): | |
success = False | |
retries = 0 | |
max_retries = N | |
while not success: | |
# Execute task, success = True if successful | |
if retries == max_retries: | |
raise Error | |
retries += 1 | |
sleep(2.**retries * 0.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment