Skip to content

Commit

Permalink
fix(codecov): add retry logic to codecov collection (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher authored Dec 22, 2024
1 parent 137e82c commit 98e141d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/updater.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# standard imports
import os
from threading import Thread
import time

# lib imports
from crowdin_api import CrowdinClient
Expand Down Expand Up @@ -44,8 +45,22 @@ def update_codecov():

url = f'{base_url}/repos?page_size=500'

response = helpers.s.get(url=url, headers=headers)
data = response.json()
max_tries = 5
count = 0
data = None
response = None
while count < max_tries:
response = helpers.s.get(url=url, headers=headers)
try:
data = response.json()
except requests.exceptions.JSONDecodeError:
count += 1
time.sleep(2 ** count) # exponential backoff
continue
break

if not data:
raise requests.exceptions.HTTPError(f'Error: {response.text}')

if response.status_code != 200:
raise requests.exceptions.HTTPError(f'Error: {data["detail"]}')
Expand Down

0 comments on commit 98e141d

Please sign in to comment.