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

Catch connection errors when populating client database list #1197

Merged
merged 1 commit into from
May 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion optimade/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ def get_child_database_links(
A list of the valid links entries from this provider that
have `link_type` `"child"`.

Raises:
RuntimeError: If the provider's index meta-database is down,
invalid, or the request otherwise fails.

"""
import requests
from optimade.models.responses import LinksResponse
Expand All @@ -121,7 +125,10 @@ def get_child_database_links(
raise RuntimeError(f"Provider {provider['id']} provides no base URL.")

links_endp = base_url + "/v1/links"
links = requests.get(links_endp)
try:
links = requests.get(links_endp, timeout=10)
except requests.ConnectionError as exc:
raise RuntimeError(f"Unable to connect to provider {provider['id']}") from exc

if links.status_code != 200:
raise RuntimeError(
Expand Down