feat: three-stage status: 获取邮件中 -> 等待处理 -> AI思考中
This commit is contained in:
13
main.py
13
main.py
@@ -8,7 +8,7 @@ import time
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from src.config import load_config
|
||||
from src.summarizer import poll_accounts, ai_process, tg_send_and_mark
|
||||
from src.tg_bot import poll_telegram
|
||||
from src.tg_bot import poll_telegram, send_thinking
|
||||
|
||||
# Thread-safe logging: all log records go through a single QueueListener thread
|
||||
_log_queue = queue_module.Queue(-1)
|
||||
@@ -55,7 +55,12 @@ def _email_poller(cfg):
|
||||
if mail.uid not in _processing_uids:
|
||||
_processing_uids.add(mail.uid)
|
||||
_pending_uids.add(mail.uid)
|
||||
_email_queue.put((acct_idx, mail))
|
||||
# 发送"获取邮件中"提示
|
||||
try:
|
||||
tg_msg_id = send_thinking(cfg.telegram, cfg.telegram.chat_id, "📥 获取邮件中...")
|
||||
except Exception:
|
||||
tg_msg_id = 0
|
||||
_email_queue.put((acct_idx, mail, tg_msg_id))
|
||||
except Exception as e:
|
||||
logger.error(f"邮件轮询线程异常: {e}", exc_info=True)
|
||||
time.sleep(5)
|
||||
@@ -74,10 +79,10 @@ def _ai_processor(cfg):
|
||||
while _running:
|
||||
while len(pending_futures) < max_workers:
|
||||
try:
|
||||
acct_idx, mail = _email_queue.get_nowait()
|
||||
acct_idx, mail, tg_msg_id = _email_queue.get_nowait()
|
||||
except queue_module.Empty:
|
||||
break
|
||||
future = executor.submit(ai_process, cfg, acct_idx, mail)
|
||||
future = executor.submit(ai_process, cfg, acct_idx, mail, tg_msg_id)
|
||||
pending_futures[future] = (acct_idx, mail)
|
||||
|
||||
completed = [f for f in pending_futures if f.done()]
|
||||
|
||||
Reference in New Issue
Block a user