Created
September 1, 2023 16:50
-
-
Save antunesleo/98cfd8011ed9b1c69e3209dc0c861c98 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
import requests | |
UNSTABLE_API = "https://httpbin.org/status/200,500,503,401" | |
def dumbretry(): | |
succeeded = False | |
attempts = 0 | |
while not succeeded: | |
response = requests.get(UNSTABLE_API) | |
succeeded = response.ok | |
attempts += 1 | |
print(f"succeded after {attempts} attempts") | |
if __name__ == "__main__": | |
dumbretry() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment