Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a timeout when fetching servers #327

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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