fix: process one queued email per poll cycle to keep callbacks responsive

This commit is contained in:
2026-07-15 18:32:42 +08:00
parent 17514302f9
commit 2744d9dd77

View File

@@ -107,14 +107,14 @@ def _tg_worker(cfg):
except Exception as e:
logger.error(f"TG 轮询错误: {e}", exc_info=True)
while _running:
# 每轮只处理一封待发邮件,然后立刻回去 poll Telegram
try:
info = _tg_queue.get_nowait()
tg_send_and_mark(cfg, info)
uid_str = info["uid"].decode("utf-8", errors="replace") if isinstance(info["uid"], bytes) else str(info["uid"])
mark_sent(uid_str)
except queue_module.Empty:
break
pass
except Exception as e:
logger.error(f"TG 发送失败: {e}", exc_info=True)
try:
@@ -124,7 +124,7 @@ def _tg_worker(cfg):
pass
if _running:
_shutdown_event.wait(1)
_shutdown_event.wait(0.2)
def main():