Skip to content

Commit

Permalink
add a timeout when fetching servers
Browse files Browse the repository at this point in the history
  • Loading branch information
ocefpaf committed Jan 10, 2024
1 parent e7dd138 commit 287b941
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions erddapy/servers/servers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""Servers."""

import functools
import io
from collections import namedtuple

import httpx
import pandas as pd


Expand All @@ -14,12 +16,11 @@ def servers_list():
If loading the latest one fails it falls back to the default one shipped with the package.
"""
from urllib.error import URLError

try:
url = "https://raw.githubusercontent.com/IrishMarineInstitute/awesome-erddap/master/erddaps.json"
df = pd.read_json(url)
except URLError:
r = httpx.get(url, timeout=10)
df = pd.read_json(io.StringIO(r.text))
except httpx.HTTPError:
from pathlib import Path

path = Path(__file__).absolute().parent
Expand Down

0 comments on commit 287b941

Please sign in to comment.