mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-21 13:48:19 +00:00
🔧 添加超时配置项
This commit is contained in:
parent
8c8e09be7b
commit
465f7c4148
@ -46,6 +46,13 @@ LOGGER_LOCALS_MAX_DEPTH=0
|
||||
LOGGER_LOCALS_MAX_LENGTH=10
|
||||
LOGGER_LOCALS_MAX_STRING=80
|
||||
|
||||
# 超时配置 可选配置项
|
||||
# TIMEOUT = 10
|
||||
# READ_TIMEOUT = 2
|
||||
# WRITE_TIMEOUT = 10
|
||||
# CONNECT_TIMEOUT = 10
|
||||
# POOL_TIMEOUT = 10
|
||||
|
||||
# mtp 客户端 可选配置项
|
||||
# API_ID=12345
|
||||
# API_HASH="abcdefg"
|
||||
|
@ -243,7 +243,14 @@ class Bot:
|
||||
try:
|
||||
for _ in range(5):
|
||||
try:
|
||||
self.app.run_polling(close_loop=False, write_timeout=10)
|
||||
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,
|
||||
)
|
||||
break
|
||||
except TimedOut:
|
||||
logger.warning("连接至 [blue]telegram[/] 服务器失败,正在重试", extra={"markup": True})
|
||||
|
@ -57,6 +57,12 @@ class BotConfig(BaseSettings):
|
||||
logger_locals_max_length: int = 10
|
||||
logger_locals_max_string: int = 80
|
||||
|
||||
timeout: int = 10
|
||||
read_timeout: float = 2
|
||||
write_timeout: Optional[float] = None
|
||||
connect_timeout: Optional[float] = None
|
||||
pool_timeout: Optional[float] = None
|
||||
|
||||
enka_network_api_agent: str = ""
|
||||
pass_challenge_api: str = ""
|
||||
pass_challenge_app_key: str = ""
|
||||
|
Loading…
Reference in New Issue
Block a user