Skip to content

Commit

Permalink
fix: status 522 cannot reload
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Jan 16, 2024
1 parent c78b941 commit b37691c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions func/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio

from httpx import AsyncClient, TimeoutException
from httpx import AsyncClient, TimeoutException, HTTPStatusError

headers = {
"authority": "api-static.mihoyo.com",
Expand All @@ -22,9 +22,15 @@

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)
Expand Down

0 comments on commit b37691c

Please sign in to comment.