Skip to content

Commit

Permalink
Very basic check for 403 (rate limit exceeded) with sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
vsoch committed Aug 28, 2021
1 parent 43419c8 commit a73f9b4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions get_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import fnmatch
import hashlib
import tempfile
import time
import shutil
import requests
import pathlib
Expand Down Expand Up @@ -132,6 +133,10 @@ def get_artifacts(repository):
while True:
params = {"per_page": 100, "page": page}
response = requests.get(ARTIFACTS_URL, params=params, headers=HEADERS)
while response.status_code == 403:
print("API rate limit likely exceeded, sleeping for 10 minutes.")
time.sleep(600)
response = requests.get(ARTIFACTS_URL, params=params, headers=HEADERS)
if response.status_code != 200:
abort_if_fail(response, "Unable to retrieve artifacts")
response = response.json()
Expand Down

0 comments on commit a73f9b4

Please sign in to comment.