Skip to content

Commit

Permalink
refactor: make NREL API downloads resilient to 5xx errors
Browse files Browse the repository at this point in the history
  • Loading branch information
danielolsen committed Jan 8, 2022
1 parent 01b94e1 commit 466a803
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions prereise/gather/solardata/nsrdb/nrel_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ def get_psm3_at(
)
def download(url):
resp = requests.get(url)
if resp.status_code // 100 == 5: # all 5xx errors, server side
raise TransientError(
f"Server side error, retry_count={download.retry_count}"
)
if resp.status_code == 429:
raise TransientError(
f"Too many requests, retry_count={download.retry_count}"
Expand Down

0 comments on commit 466a803

Please sign in to comment.