fix(beatmap): always retry when status_code >= 400
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from .beatmap import BeatmapFetcher
|
from .beatmap import BeatmapFetcher
|
||||||
|
from .beatmap_raw import BeatmapRawFetcher
|
||||||
from .beatmapset import BeatmapsetFetcher
|
from .beatmapset import BeatmapsetFetcher
|
||||||
from .osu_dot_direct import BeatmapRawFetcher
|
|
||||||
|
|
||||||
|
|
||||||
class Fetcher(BeatmapFetcher, BeatmapsetFetcher, BeatmapRawFetcher):
|
class Fetcher(BeatmapFetcher, BeatmapsetFetcher, BeatmapRawFetcher):
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from ._base import BaseFetcher
|
from ._base import BaseFetcher
|
||||||
|
|
||||||
from httpx import AsyncClient
|
from httpx import AsyncClient, HTTPError
|
||||||
from httpx._models import Response
|
from httpx._models import Response
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
import redis.asyncio as redis
|
import redis.asyncio as redis
|
||||||
@@ -22,12 +22,10 @@ class BeatmapRawFetcher(BaseFetcher):
|
|||||||
f"<blue>[BeatmapRawFetcher]</blue> get_beatmap_raw: <y>{req_url}</y>"
|
f"<blue>[BeatmapRawFetcher]</blue> get_beatmap_raw: <y>{req_url}</y>"
|
||||||
)
|
)
|
||||||
resp = await self._request(req_url)
|
resp = await self._request(req_url)
|
||||||
if resp.status_code == 429:
|
if resp.status_code >= 400:
|
||||||
continue
|
continue
|
||||||
elif resp.status_code < 400:
|
|
||||||
return resp.text
|
return resp.text
|
||||||
else:
|
raise HTTPError("Failed to fetch beatmap")
|
||||||
resp.raise_for_status()
|
|
||||||
|
|
||||||
async def _request(self, url: str) -> Response:
|
async def _request(self, url: str) -> Response:
|
||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
Reference in New Issue
Block a user