Handle ReadTimeout error

This commit is contained in:
mungai-njoroge 2023-07-01 20:39:09 +03:00
parent f5de09bd09
commit 95214396e7
3 changed files with 7 additions and 2 deletions

2
.gitignore vendored
View File

@ -23,3 +23,5 @@ dist
build
client
.gitignore
logs.txt

View File

@ -6,7 +6,7 @@ import requests
from app import settings
from app.utils.hashing import create_hash
from requests import ConnectionError
from requests import ConnectionError, ReadTimeout
import urllib.parse
@ -19,7 +19,7 @@ def fetch_similar_artists(name: str):
try:
response = requests.get(url, timeout=10)
response.raise_for_status()
except ConnectionError:
except (ConnectionError, ReadTimeout):
return []
data = response.json()

View File

@ -2,6 +2,7 @@
This file is used to run the application.
"""
import logging
# import sys
from app.api import create_api
from app.arg_handler import HandleArgs
@ -13,6 +14,8 @@ from app.start_info_logger import log_startup_info
from app.utils.filesystem import get_home_res_path
from app.utils.threading import background
# sys.stderr = open("./logs.txt", "w")
werkzeug = logging.getLogger("werkzeug")
werkzeug.setLevel(logging.ERROR)