add retries for genius/lrclib searches (tenacity) + reduce timeouts appropriately
This commit is contained in:
@ -6,6 +6,9 @@ import traceback
|
||||
import logging
|
||||
from typing import Optional, Union
|
||||
from aiohttp import ClientTimeout, ClientSession
|
||||
from tenacity import (
|
||||
retry, stop_after_attempt, wait_fixed
|
||||
)
|
||||
from lyric_search import utils
|
||||
from lyric_search.constructors import LyricsResult
|
||||
from . import common, cache, redis_cache
|
||||
@ -22,12 +25,13 @@ class LRCLib:
|
||||
self.label: str = "LRCLib"
|
||||
self.lrclib_url: str = "https://lrclib.net/api/search"
|
||||
self.headers: dict = common.SCRAPE_HEADERS
|
||||
self.timeout = ClientTimeout(connect=2, sock_read=4)
|
||||
self.timeout = ClientTimeout(connect=2, sock_read=3)
|
||||
self.datautils = utils.DataUtils()
|
||||
self.matcher = utils.TrackMatcher()
|
||||
self.cache = cache.Cache()
|
||||
self.redis_cache = redis_cache.RedisCache()
|
||||
|
||||
@retry(stop=stop_after_attempt(2), wait=wait_fixed(0.5))
|
||||
async def search(
|
||||
self, artist: str, song: str, plain: Optional[bool] = True
|
||||
) -> Optional[LyricsResult]:
|
||||
|
Reference in New Issue
Block a user