From 15975e47022ed32ef6f54f580777c14ea5dac3f4 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 28 May 2024 10:03:58 +0200 Subject: [PATCH] Except YouTube Error 429: Too Many Requests (#13167) Co-authored-by: UltralyticsAssistant --- tests/test_python.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_python.py b/tests/test_python.py index 184f8945..a52f7d6e 100644 --- a/tests/test_python.py +++ b/tests/test_python.py @@ -1,6 +1,7 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license import contextlib +import urllib from copy import copy from pathlib import Path @@ -19,6 +20,7 @@ from ultralytics.utils import ( ASSETS, DEFAULT_CFG, DEFAULT_CFG_PATH, + LOGGER, ONLINE, ROOT, WEIGHTS_DIR, @@ -136,7 +138,10 @@ def test_youtube(): Note: ConnectionError may occur during this test due to network instability or YouTube server availability. """ model = YOLO(MODEL) - model.predict("https://youtu.be/G17sBkb38XQ", imgsz=96, save=True) + try: + model.predict("https://youtu.be/G17sBkb38XQ", imgsz=96, save=True) + except urllib.error.HTTPError as e: # handle 'urllib.error.HTTPError: HTTP Error 429: Too Many Requests' + LOGGER.warning(f"WARNING: YouTube Test Error: {e}") @pytest.mark.skipif(not ONLINE, reason="environment is offline")