Skip to content

Commit

Permalink
add timeout when downloading files
Browse files Browse the repository at this point in the history
  • Loading branch information
flopp committed Apr 9, 2024
1 parent cc03cab commit 2a8fbe1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/us_capitals.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"https://gist.githubusercontent.com/jpriebe/d62a45e29f24e843c974/"
"raw/b1d3066d245e742018bce56e41788ac7afa60e29/us_state_capitals.json"
)
response = requests.get(URL)
response = requests.get(URL, timeout=10)
for _, data in json.loads(response.text).items():
capital = staticmaps.create_latlng(float(data["lat"]), float(data["long"]))
context.add_object(staticmaps.Marker(capital, size=5))
Expand Down
2 changes: 1 addition & 1 deletion staticmaps/tile_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def get(self, provider: TileProvider, cache_dir: str, zoom: int, x: int, y: int)
url = provider.url(zoom, x, y)
if url is None:
return None
res = requests.get(url, headers={"user-agent": self._user_agent})
res = requests.get(url, headers={"user-agent": self._user_agent}, timeout=10)
if res.status_code == 200:
data = res.content
else:
Expand Down

0 comments on commit 2a8fbe1

Please sign in to comment.