Skip to content

Commit

Permalink
Try 3 times instead of 2, handle failure more consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
dschuff committed Dec 18, 2024
1 parent 454aadb commit bb499d3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions document/util/check-echidna-status.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ def get_echidna_id(directory):
def get_current_response(echidna_id):
url = ECHIDNA_STATUS_URL + echidna_id
print(f'Fetching {url}')
retry = 2
while retry:
tries = 3
while tries:
response = requests.get(url, allow_redirects=True)
if response.status_code == 200:
return response.json()

print(f'Got status code {response.status_code}, text:')
print(response.text)
retry -= 1
if retry:
tries -= 1
if tries:
print('Retrying in 5s')
time.sleep(5)

Expand All @@ -50,15 +50,19 @@ def get_echidna_result(echidna_id):
result = response['results']['status']
print(f'Echidna issue {echidna_id} is {result}.')
print(json.dumps(response, indent=2))
return result == 'success'
if result != 'success':
raise Exception(f'Echidna result: {result}')


def main(argv):
directory = os.getcwd() if len(argv) < 2 else argv[1]
echidna_id = get_echidna_id(directory)
print(f'Got echidna id {echidna_id}.')
time.sleep(5)
if not get_echidna_result(echidna_id):
try:
get_echidna_result(echidna_id)
except Exception as e:
print(f'Echidna failure: {e}')
sys.exit(1)


Expand Down

0 comments on commit bb499d3

Please sign in to comment.