Skip to content

fix: Use urllib to make _offline() aware of HTTP(s) proxies. #150

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions src/anemoi/utils/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,12 @@ def _run_slow_tests() -> bool:
@lru_cache(maxsize=None)
def _offline() -> bool:
"""Check if we are offline."""

import socket
from urllib import request

try:
socket.create_connection(("anemoi.ecmwf.int", 443), timeout=5)
except OSError:
request.urlopen("https://anemoi.ecmwf.int", timeout=1)
return False
except request.URLError:
return True

return False
Expand Down
Loading