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 633021b commit 1109100
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 "Request was throttled" in page.get("detail", ""):
raise e
else:
self.stdout.write(f"Error: {e}")
url = page.get("next")
Person.objects.filter(ynr_id__in=merged_ids).delete()

Expand Down

0 comments on commit 1109100

Please sign in to comment.