mirror of
https://github.com/PaiGramTeam/HonkaiStarRailWikiDataParser.git
synced 2025-01-30 18:38:36 +00:00
fix: status 522 cannot reload
This commit is contained in:
parent
c78b941509
commit
b37691c956
@ -1,6 +1,6 @@
|
||||
import asyncio
|
||||
|
||||
from httpx import AsyncClient, TimeoutException
|
||||
from httpx import AsyncClient, TimeoutException, HTTPStatusError
|
||||
|
||||
headers = {
|
||||
"authority": "api-static.mihoyo.com",
|
||||
@ -22,9 +22,15 @@ client = AsyncClient(headers=headers, timeout=120.0)
|
||||
|
||||
def retry(func):
|
||||
async def wrapper(*args, **kwargs):
|
||||
for i in range(3):
|
||||
for i in range(5):
|
||||
try:
|
||||
return await func(*args, **kwargs)
|
||||
except HTTPStatusError as exc:
|
||||
if exc.response.status_code == 522:
|
||||
print(f"重试 {func.__name__} {i + 1} 次")
|
||||
await asyncio.sleep(1)
|
||||
else:
|
||||
raise exc
|
||||
except TimeoutException:
|
||||
print(f"重试 {func.__name__} {i + 1} 次")
|
||||
await asyncio.sleep(1)
|
||||
|
Loading…
Reference in New Issue
Block a user