perf: reduce poll timeout to 1s and wait to 50ms for faster button response
This commit is contained in:
2
main.py
2
main.py
@@ -110,7 +110,7 @@ def _tg_poller(cfg):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"TG 轮询错误: {e}", exc_info=True)
|
logger.error(f"TG 轮询错误: {e}", exc_info=True)
|
||||||
if _running:
|
if _running:
|
||||||
_shutdown_event.wait(0.1)
|
_shutdown_event.wait(0.05)
|
||||||
|
|
||||||
|
|
||||||
def _tg_sender(cfg):
|
def _tg_sender(cfg):
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ def poll_telegram(tg_cfg: TelegramConfig, cfg: Config, last_update_id: int) -> i
|
|||||||
try:
|
try:
|
||||||
resp = requests.get(
|
resp = requests.get(
|
||||||
f"https://api.telegram.org/bot{tg_cfg.bot_token}/getUpdates",
|
f"https://api.telegram.org/bot{tg_cfg.bot_token}/getUpdates",
|
||||||
params={"offset": last_update_id, "timeout": 2},
|
params={"offset": last_update_id, "timeout": 1},
|
||||||
timeout=10,
|
timeout=10,
|
||||||
)
|
)
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
|
|||||||
Reference in New Issue
Block a user