mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-07 03:35:35 +00:00
Handle ReadTimeout error
This commit is contained in:
parent
f5de09bd09
commit
95214396e7
2
.gitignore
vendored
2
.gitignore
vendored
@ -23,3 +23,5 @@ dist
|
|||||||
build
|
build
|
||||||
client
|
client
|
||||||
.gitignore
|
.gitignore
|
||||||
|
|
||||||
|
logs.txt
|
@ -6,7 +6,7 @@ import requests
|
|||||||
|
|
||||||
from app import settings
|
from app import settings
|
||||||
from app.utils.hashing import create_hash
|
from app.utils.hashing import create_hash
|
||||||
from requests import ConnectionError
|
from requests import ConnectionError, ReadTimeout
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ def fetch_similar_artists(name: str):
|
|||||||
try:
|
try:
|
||||||
response = requests.get(url, timeout=10)
|
response = requests.get(url, timeout=10)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
except ConnectionError:
|
except (ConnectionError, ReadTimeout):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
This file is used to run the application.
|
This file is used to run the application.
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
# import sys
|
||||||
|
|
||||||
from app.api import create_api
|
from app.api import create_api
|
||||||
from app.arg_handler import HandleArgs
|
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.filesystem import get_home_res_path
|
||||||
from app.utils.threading import background
|
from app.utils.threading import background
|
||||||
|
|
||||||
|
# sys.stderr = open("./logs.txt", "w")
|
||||||
|
|
||||||
werkzeug = logging.getLogger("werkzeug")
|
werkzeug = logging.getLogger("werkzeug")
|
||||||
werkzeug.setLevel(logging.ERROR)
|
werkzeug.setLevel(logging.ERROR)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user