mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-16 04:35:49 +00:00
🎨 Update Networking backend tweaks
This commit is contained in:
parent
f564a1db02
commit
9d8d6deda7
22
.env.example
22
.env.example
@ -50,13 +50,21 @@ LOGGER_LOCALS_MAX_STRING=80
|
||||
# 可被 logger 打印的 record 的名称(默认包含了 LOGGER_NAME )
|
||||
LOGGER_FILTERED_NAMES=["uvicorn","ErrorPush","ApiHelper"]
|
||||
|
||||
|
||||
# 超时配置 可选配置项
|
||||
# TIMEOUT = 10
|
||||
# READ_TIMEOUT = 2
|
||||
# WRITE_TIMEOUT = 10
|
||||
# CONNECT_TIMEOUT = 10
|
||||
# POOL_TIMEOUT = 10
|
||||
# Request 超时配置 可选配置项
|
||||
# READ_TIMEOUT=7
|
||||
# 指定等待服务器响应的最长时间
|
||||
# WRITE_TIMEOUT=10
|
||||
# 指定等待写入操作完成的最长时间(就网络套接字而言,即请求或上传一个文件)
|
||||
# CONNECT_TIMEOUT=10
|
||||
# 指定等待连接到服务器的最长时间
|
||||
# POOL_TIMEOUT=10
|
||||
# Bot.Update 超时配置
|
||||
# TIMEOUT=10
|
||||
# 服务器出现故障时Updater的引导阶段重试时间
|
||||
# UPDATE_READ_TIMEOUT=42
|
||||
# UPDATE_WRITE_TIMEOUT=10
|
||||
# UPDATE_CONNECT_TIMEOUT=10
|
||||
# UPDATE_POOL_TIMEOUT=10
|
||||
|
||||
# genshin.py 缓存配置 可选配置项
|
||||
# GENSHIN_TTL = 3600
|
||||
|
12
core/bot.py
12
core/bot.py
@ -259,6 +259,14 @@ class Bot:
|
||||
logger.info("正在初始化BOT")
|
||||
self.app = (
|
||||
TgApplication.builder()
|
||||
.read_timeout(self.config.read_timeout)
|
||||
.write_timeout(self.config.write_timeout)
|
||||
.connect_timeout(self.config.connect_timeout)
|
||||
.pool_timeout(self.config.pool_timeout)
|
||||
.get_updates_read_timeout(self.config.update_read_timeout)
|
||||
.get_updates_write_timeout(self.config.update_write_timeout)
|
||||
.get_updates_connect_timeout(self.config.update_connect_timeout)
|
||||
.get_updates_pool_timeout(self.config.update_pool_timeout)
|
||||
.rate_limiter(AIORateLimiter())
|
||||
.defaults(Defaults(tzinfo=pytz.timezone("Asia/Shanghai")))
|
||||
.token(self._config.bot_token)
|
||||
@ -271,10 +279,6 @@ class Bot:
|
||||
self.app.run_polling(
|
||||
close_loop=False,
|
||||
timeout=self.config.timeout,
|
||||
read_timeout=self.config.read_timeout,
|
||||
write_timeout=self.config.write_timeout,
|
||||
connect_timeout=self.config.connect_timeout,
|
||||
pool_timeout=self.config.pool_timeout,
|
||||
allowed_updates=Update.ALL_TYPES,
|
||||
)
|
||||
break
|
||||
|
@ -122,10 +122,14 @@ class BotConfig(Settings):
|
||||
join_groups: Optional[JoinGroups] = JoinGroups.NO_ALLOW
|
||||
|
||||
timeout: int = 10
|
||||
read_timeout: float = 2
|
||||
read_timeout: Optional[float] = None
|
||||
write_timeout: Optional[float] = None
|
||||
connect_timeout: Optional[float] = None
|
||||
pool_timeout: Optional[float] = None
|
||||
update_read_timeout: Optional[float] = None
|
||||
update_write_timeout: Optional[float] = None
|
||||
update_connect_timeout: Optional[float] = None
|
||||
update_pool_timeout: Optional[float] = None
|
||||
|
||||
genshin_ttl: Optional[int] = None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user