From c54b013188870dafdd5ce0d78b3f5f3fdee655fd Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 16 Apr 2024 20:09:11 -0700 Subject: [PATCH] Check Google DNS for `is_online()` (#10095) --- .github/workflows/ci.yaml | 2 +- ultralytics/utils/__init__.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index edcde05ee5..da2072dab6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -126,7 +126,7 @@ jobs: run: coverage run -a --source=ultralytics -m ultralytics.cfg.__init__ benchmark model='path with spaces/yolov8s-worldv2.pt' imgsz=160 verbose=0.318 - name: Benchmark SegmentationModel shell: bash - run: coverage run -a --source=ultralytics -m ultralytics.cfg.__init__ benchmark model='path with spaces/${{ matrix.model }}-seg.pt' imgsz=160 verbose=0.280 + run: coverage run -a --source=ultralytics -m ultralytics.cfg.__init__ benchmark model='path with spaces/${{ matrix.model }}-seg.pt' imgsz=160 verbose=0.279 - name: Benchmark PoseModel shell: bash run: coverage run -a --source=ultralytics -m ultralytics.cfg.__init__ benchmark model='path with spaces/${{ matrix.model }}-pose.pt' imgsz=160 verbose=0.183 diff --git a/ultralytics/utils/__init__.py b/ultralytics/utils/__init__.py index 77745014c9..5a293f5c2d 100644 --- a/ultralytics/utils/__init__.py +++ b/ultralytics/utils/__init__.py @@ -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