packager_alias: Allow for sporadic failures in retrieving info from dist-git
Basically, if we fail to retrieve data from pagure or we fail to convert from JSON, wait for 30 seconds and retry. If after two minutes (4 attempts) it still hasn't worked, bail. Fixes https://pagure.io/fedora-infrastructure/issue/7603 Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
parent
5fd5b37321
commit
0db6035454
1 changed files with 15 additions and 2 deletions
|
@ -6,6 +6,8 @@ This script is ran as a cronjob and bastion.
|
|||
Its goal is to generate all the <pkg>-owner email aliases we provide
|
||||
"""
|
||||
|
||||
import time
|
||||
|
||||
import requests
|
||||
|
||||
from requests.adapters import HTTPAdapter
|
||||
|
@ -36,8 +38,19 @@ def get_pagure_projects():
|
|||
pagure_projects_url = pagure_url + '/api/0/projects?page=1&per_page=100&fork=false'
|
||||
session = retry_session()
|
||||
while pagure_projects_url:
|
||||
response = session.get(pagure_projects_url)
|
||||
data = response.json()
|
||||
cnt = 0
|
||||
while True:
|
||||
try:
|
||||
response = session.get(pagure_projects_url)
|
||||
data = response.json()
|
||||
break
|
||||
except Exception:
|
||||
if cnt == 4:
|
||||
raise
|
||||
|
||||
cnt += 1
|
||||
time.sleep(30)
|
||||
|
||||
for project in data['projects']:
|
||||
yield project
|
||||
# This is set to None on the last page.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue