Check Google DNS for is_online() (#10095)

This commit is contained in:
Glenn Jocher 2024-04-16 20:09:11 -07:00 committed by GitHub
parent 03badaff57
commit c54b013188
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View file

@ -512,8 +512,9 @@ def is_online() -> bool:
assert str(os.getenv("YOLO_OFFLINE", "")).lower() != "true" # check if ENV var YOLO_OFFLINE="True"
import socket
socket.create_connection(address=("1.1.1.1", 80), timeout=1.0).close() # check Cloudflare DNS
return True
for dns in ("1.1.1.1", "8.8.8.8"): # check Cloudflare and Google DNS
socket.create_connection(address=(dns, 80), timeout=1.0).close()
return True
return False