Skip to content

Commit

Permalink
Handle exception for rate limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
VirginiaDooley committed Oct 24, 2023
1 parent e7ef04c commit 9f1419f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions wcivf/apps/people/management/commands/import_people.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,14 @@ def delete_merged_people(self):
while url:
req = requests.get(url)
page = req.json()
for result in page["results"]:
merged_ids.append(result["old_person_id"])
try:
for result in page["results"]:
merged_ids.append(result["old_person_id"])
except KeyError as e:
if not "Request was throttled" in page.get("detail", ""):
self.stdout.write(f"Error: {e}")
else:
raise e
url = page.get("next")
Person.objects.filter(ynr_id__in=merged_ids).delete()

Expand Down

0 comments on commit 9f1419f

Please sign in to comment.