2022-09-27 15:52:32 +00:00
|
|
|
import asyncio
|
2022-10-11 06:45:07 +00:00
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
import aiohttp # pylint: disable=W0406
|
2023-03-14 01:27:22 +00:00
|
|
|
from aiohttp import ClientError
|
2022-09-27 15:52:32 +00:00
|
|
|
|
|
|
|
from utils.patch.methods import patch, patchable
|
|
|
|
|
|
|
|
|
2023-03-14 01:27:22 +00:00
|
|
|
class AioHttpTimeoutException(ClientError):
|
2022-09-27 15:52:32 +00:00
|
|
|
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
|