Skip to content

Commit

Permalink
made sure all HTTPErrors are captured and retried and included the …
Browse files Browse the repository at this point in the history
…last error/reason message when max_retries is reached (#248)
  • Loading branch information
veenstrajelmer authored Aug 13, 2024
1 parent 82960dc commit cda9ee2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions contextily/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,15 @@ def _retryer(tile_url, wait, max_retries):
"Tile URL resulted in a 404 error. "
"Double-check your tile url:\n{}".format(tile_url)
)
elif request.status_code == 104 or request.status_code == 200:
else:
if max_retries > 0:
time.sleep(wait)
max_retries -= 1
request = _retryer(tile_url, wait, max_retries)
else:
raise requests.HTTPError("Connection reset by peer too many times.")

raise requests.HTTPError("Connection reset by peer too many times. "
f"Last message was: {request.status_code} "
f"Error: {request.reason} for url: {request.url}")

def howmany(w, s, e, n, zoom, verbose=True, ll=False):
"""
Expand Down

0 comments on commit cda9ee2

Please sign in to comment.