mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-16 12:02:16 +00:00
25 lines
840 B
Python
25 lines
840 B
Python
|
import simnet
|
||
|
from httpx import AsyncClient, Timeout, Limits
|
||
|
|
||
|
from core.config import config
|
||
|
from utils.patch.methods import patch, patchable
|
||
|
|
||
|
|
||
|
@patch(simnet.StarRailClient)
|
||
|
class StarRailClient:
|
||
|
@patchable
|
||
|
def __init__(self, *args, **kwargs):
|
||
|
self.old___init__(*args, **kwargs)
|
||
|
self.client: AsyncClient
|
||
|
if config.connect_timeout and config.read_timeout and config.write_timeout and config.pool_timeout:
|
||
|
self.client.timeout = Timeout(
|
||
|
connect=config.connect_timeout,
|
||
|
read=config.read_timeout,
|
||
|
write=config.write_timeout,
|
||
|
pool=config.pool_timeout,
|
||
|
)
|
||
|
self.client.limits = Limits(
|
||
|
max_connections=config.connection_pool_size,
|
||
|
max_keepalive_connections=config.connection_pool_size,
|
||
|
)
|