From 5ca739456dbf3d880c7383f6d2d8e97953d866c0 Mon Sep 17 00:00:00 2001 From: Zichao Lin Date: Wed, 15 Jul 2026 19:20:52 +0800 Subject: [PATCH] perf: reduce poll timeout to 1s and wait to 50ms for faster button response --- main.py | 2 +- src/tg_bot.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index eccbefd..7c9a038 100644 --- a/main.py +++ b/main.py @@ -110,7 +110,7 @@ def _tg_poller(cfg): except Exception as e: logger.error(f"TG 轮询错误: {e}", exc_info=True) if _running: - _shutdown_event.wait(0.1) + _shutdown_event.wait(0.05) def _tg_sender(cfg): diff --git a/src/tg_bot.py b/src/tg_bot.py index 34ddd6c..4b7611d 100644 --- a/src/tg_bot.py +++ b/src/tg_bot.py @@ -86,7 +86,7 @@ def poll_telegram(tg_cfg: TelegramConfig, cfg: Config, last_update_id: int) -> i try: resp = requests.get( 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, ) resp.raise_for_status()