Commit 35475576 authored by Tom Powell's avatar Tom Powell

Retry gitlab api call

Gitlab keeps randomly timing out. Ignore those timeouts. 
parent 177732fe
......@@ -15,6 +15,14 @@ if not project or not trigger_token or not access_token:
project = quote_plus(project)
def retry(func, *args, **kwargs):
return func(*args, **kwargs)
except Exception as e:
print(f"Internal error, retrying: {e}")
return retry(func, args, **kwargs)
def start(device, version, type_, pipeline_id):
gitlab_url = f"{project}/trigger/pipeline?token={trigger_token}&ref=master"
data = {
......@@ -36,7 +44,7 @@ def main():
gitlab_url = f"{project}/pipelines/{pipeline_id}"
headers = {'Private-Token': access_token}
while True:
resp = requests.get(gitlab_url, headers=headers)
resp = retry(requests.get, gitlab_url, headers=headers)
if resp.status_code == 200:
status = resp.json().get("status")
if status == "success":
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment