mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-05-09 05:25:48 +08:00
⚡ 在部分请求中使用httpx
替换aiohttp
This commit is contained in:
parent
cf2e874e7e
commit
bc93c66bc6
@ -21,6 +21,7 @@ from typing import (
|
||||
overload,
|
||||
)
|
||||
|
||||
import httpx
|
||||
from aiohttp import TCPConnector, ClientSession, ContentTypeError
|
||||
|
||||
from gsuid_core.logger import logger
|
||||
@ -387,9 +388,7 @@ class BaseMysApi:
|
||||
else:
|
||||
proxy = None
|
||||
|
||||
async with ClientSession(
|
||||
connector=TCPConnector(verify_ssl=ssl_verify)
|
||||
) as client:
|
||||
async with httpx.AsyncClient(verify=ssl_verify, proxy=proxy) as client:
|
||||
raw_data = {}
|
||||
uid = None
|
||||
if params and 'role_id' in params:
|
||||
@ -417,19 +416,18 @@ class BaseMysApi:
|
||||
|
||||
logger.debug(header)
|
||||
for _ in range(2):
|
||||
async with client.request(
|
||||
resp = await client.request(
|
||||
method,
|
||||
url=url,
|
||||
headers=header,
|
||||
params=params,
|
||||
json=data,
|
||||
proxy=proxy,
|
||||
timeout=300,
|
||||
) as resp:
|
||||
)
|
||||
try:
|
||||
raw_data = await resp.json()
|
||||
raw_data = resp.json()
|
||||
except ContentTypeError:
|
||||
_raw_data = await resp.text()
|
||||
_raw_data = resp.text
|
||||
raw_data = {'retcode': -999, 'data': _raw_data}
|
||||
|
||||
logger.debug(raw_data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user