Commit 49eac26c authored by Pietro Albini's avatar Pietro Albini

Retry requests if Launchpad fails to reply

parent 47f1682a
Pipeline #80 passed with stage
in 0 seconds
......@@ -23,8 +23,15 @@ BASE = "https://api.launchpad.net/devel"
def fetch_paginated(initial):
"""Fetch paginated data"""
next_url = initial
while True:
data = requests.get(next_url).json()
retry_count = 0
while retry_count < 5:
resp = requests.get(next_url)
if resp.status_code == 200:
retry_count = 0
data = resp.json()
else:
retry_count += 1
continue
for entry in data["entries"]:
yield entry
......@@ -33,6 +40,9 @@ def fetch_paginated(initial):
break
next_url = data["next_collection_link"]
if retry_count:
raise RuntimeError("Failed to contact launchpad!")
def get_cdimage_mirrors(distro, country):
"""Get a list of cdimage mirrors"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment