packager_alias: Another fix for when somehow pagure doesn't return JSON data
From the logs of this cron job running, it appears that every now and then
a request to pagure isn't returning JSON data. Could be because the server
got restarted in the middle or something else.
The result is however the same, the request's data can't be converted to
JSON.
This commit is an addition to 0db6035454
which
was already taking care of a similar issue but when retrieving project
information, this one is for retrieving groups information.
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
parent
3ace92fcf8
commit
62405a2753
1 changed files with 14 additions and 2 deletions
|
@ -72,8 +72,20 @@ for project in get_pagure_projects():
|
|||
if group in group_data:
|
||||
users = users | group_data[group]
|
||||
continue
|
||||
group_members = session.get(
|
||||
pagure_group_url.format(group=group)).json()['members']
|
||||
|
||||
cnt = 0
|
||||
while True:
|
||||
try:
|
||||
response = session.get(pagure_group_url.format(group=group))
|
||||
data = response.json()
|
||||
break
|
||||
except Exception:
|
||||
if cnt == 4:
|
||||
raise
|
||||
cnt += 1
|
||||
time.sleep(30)
|
||||
|
||||
group_members = data['members']
|
||||
users = users | set(group_members)
|
||||
group_data[group] = set(group_members)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue