summaryrefslogtreecommitdiff
path: root/ATRI/utils/request.py
diff options
context:
space:
mode:
author0w0 <[email protected]>2022-09-21 12:04:35 +0800
committerGitHub <[email protected]>2022-09-21 12:04:35 +0800
commit1f458f9b279368354ccad224100abd59566f4ef3 (patch)
tree712f3ac05765c0e3d8cbd6e292602dc86a132dce /ATRI/utils/request.py
parent87bb8add6cbfa0797f8b3eba66c643a8045db154 (diff)
parentbd68ad78c8879143e37523d679cb643578db13c5 (diff)
downloadATRI-1f458f9b279368354ccad224100abd59566f4ef3.tar.gz
ATRI-1f458f9b279368354ccad224100abd59566f4ef3.tar.bz2
ATRI-1f458f9b279368354ccad224100abd59566f4ef3.zip
🔀 Merge pull request #61 from yangrq1018/main
Request Fix
Diffstat (limited to 'ATRI/utils/request.py')
-rw-r--r--ATRI/utils/request.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/ATRI/utils/request.py b/ATRI/utils/request.py
index 04d7093..d8f7be5 100644
--- a/ATRI/utils/request.py
+++ b/ATRI/utils/request.py
@@ -3,6 +3,9 @@ import httpx
from ATRI.config import BotSelfConfig
from ATRI.log import logger as log
+timeout = BotSelfConfig.request_timeout
+if timeout:
+ timeout = httpx.Timeout(timeout)
if not BotSelfConfig.proxy:
proxy = dict()
@@ -12,11 +15,11 @@ else:
async def get(url: str, **kwargs):
log.debug(f"GET {url} by {proxy if proxy else 'No proxy'} | MORE: \n {kwargs}")
- async with httpx.AsyncClient(proxies=proxy) as client: # type: ignore
+ async with httpx.AsyncClient(proxies=proxy, timeout=timeout) as client: # type: ignore
return await client.get(url, **kwargs)
async def post(url: str, **kwargs):
log.debug(f"POST {url} by {proxy if proxy else 'No proxy'} | MORE: \n {kwargs}")
- async with httpx.AsyncClient(proxies=proxy) as client: # type: ignore
+ async with httpx.AsyncClient(proxies=proxy, timeout=timeout) as client: # type: ignore
return await client.post(url, **kwargs)