diff --git a/src/mirrors/tasks.py b/src/mirrors/tasks.py index 614f94e..f0bc7f2 100644 --- a/src/mirrors/tasks.py +++ b/src/mirrors/tasks.py @@ -1,3 +1,5 @@ +import logging + import requests from src.database import get_db_session @@ -7,10 +9,16 @@ from src.utils import repeat_every @repeat_every(seconds=600) def update_rsf_mirrors(): - with get_db_session() as db: - r = requests.get( - "https://raw.githubusercontent.com/RSF-RWB/collateralfreedom/refs/heads/main/sites.json" - ) - mirrors = r.json() - refresh_mirrors(db, -2, mirrors) # Tracking as hardcoded pool -2 - db.commit() + try: + r = requests.get( + "https://raw.githubusercontent.com/RSF-RWB/collateralfreedom/refs/heads/main/sites.json", + timeout = 30, + ) + r.raise_for_status() + mirrors = r.json() + except (requests.RequestException, ValueError) as e: + logging.exception(e) + return + with get_db_session() as db: + refresh_mirrors(db, -2, mirrors) # Tracking as hardcoded pool -2 + db.commit() \ No newline at end of file