Skip to content

Instantly share code, notes, and snippets.

@antunesleo
Created September 1, 2023 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antunesleo/98cfd8011ed9b1c69e3209dc0c861c98 to your computer and use it in GitHub Desktop.
Save antunesleo/98cfd8011ed9b1c69e3209dc0c861c98 to your computer and use it in GitHub Desktop.
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