fix: handle failures fetching rsf list
This commit is contained in:
parent
ac03da59dc
commit
97fc9a5ab9
1 changed files with 15 additions and 7 deletions
|
|
@ -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:
|
||||
try:
|
||||
r = requests.get(
|
||||
"https://raw.githubusercontent.com/RSF-RWB/collateralfreedom/refs/heads/main/sites.json"
|
||||
"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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue