mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-25 18:04:10 +00:00
20 lines
461 B
Python
20 lines
461 B
Python
|
import asyncio
|
||
|
import aiohttp
|
||
|
|
||
|
from utils.patch.methods import patch, patchable
|
||
|
from typing import Optional
|
||
|
|
||
|
|
||
|
class AioHttpTimeoutException(asyncio.TimeoutError):
|
||
|
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
|