Skip to content

Commit

Permalink
Add retry
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Sep 19, 2024
1 parent 818f7bf commit 7e17bef
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from time import time
from typing import Dict

import pytest
Expand Down Expand Up @@ -32,7 +33,16 @@
)
def test_url(url: str, params: Dict[str, str], timeout: int) -> None:
"""Tests that some URL didn't return an error."""
response = requests.get(url, params=params, verify=False, timeout=timeout) # nosec
code = 503
count = 0
while code == 503 and count < 5:
response = requests.get(url, params=params, verify=False, timeout=timeout)
code = response.status_code
count += 1
if code == 503:
print(f"Retry {count} for {url}")
time.sleep(1)

assert response.status_code == 200, response.text


Expand Down

0 comments on commit 7e17bef

Please sign in to comment.