🔥 Remove aiohttp

This commit is contained in:
luoshuijs 2023-09-06 11:21:54 +08:00 committed by GitHub
parent 1f73588e28
commit f401725ab0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 39 deletions

View File

@ -4,7 +4,6 @@ import traceback
from typing import Optional
import aiofiles
from aiohttp import ClientError, ClientConnectorError
from httpx import HTTPError, TimeoutException
from simnet.errors import (
DataNotPublic,
@ -33,7 +32,6 @@ from modules.errorpush import (
)
from plugins.tools.genshin import CookiesNotFoundError, PlayerNotFoundError as GenshinPlayerNotFoundError
from utils.log import logger
from utils.patch.aiohttp import AioHttpTimeoutException
try:
import ujson as jsonlib
@ -235,20 +233,6 @@ class ErrorHandler(Plugin):
self.create_notice_task(update, context, notice)
raise ApplicationHandlerStop
@error_handler()
async def process_aiohttp_exception(self, update: object, context: CallbackContext):
if not isinstance(context.error, ClientError) or not isinstance(update, Update):
return
exc = context.error
notice: Optional[str] = None
if isinstance(exc, AioHttpTimeoutException):
notice = self.ERROR_MSG_PREFIX + " 服务器熟啦 ~ 请稍后再试"
elif isinstance(exc, ClientConnectorError):
notice = self.ERROR_MSG_PREFIX + " 连接服务器异常"
if notice:
self.create_notice_task(update, context, notice)
raise ApplicationHandlerStop
@error_handler()
async def process_player_and_cookie_not_found(self, update: object, context: CallbackContext):
if not isinstance(

View File

@ -1,3 +1,3 @@
from utils.patch import aiohttp, simnet
from utils.patch import simnet
__all__ = ["aiohttp", "simnet"]
__all__ = ["simnet"]

View File

@ -1,21 +0,0 @@
import asyncio
from typing import Optional
import aiohttp # pylint: disable=W0406
from aiohttp import ClientError
from utils.patch.methods import patch, patchable
class AioHttpTimeoutException(ClientError):
pass
@patch(aiohttp.helpers.TimerContext)
class TimerContext:
@patchable
def __exit__(self, *args, **kwargs) -> Optional[bool]:
try:
return self.old___exit__(*args, **kwargs)
except asyncio.TimeoutError:
raise AioHttpTimeoutException from None