fix: process one queued email per poll cycle to keep callbacks responsive
This commit is contained in:
28
main.py
28
main.py
@@ -107,24 +107,24 @@ 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:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"TG 发送失败: {e}", exc_info=True)
|
||||
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
|
||||
except Exception as e:
|
||||
logger.error(f"TG 发送失败: {e}", exc_info=True)
|
||||
try:
|
||||
uid_str = info["uid"].decode("utf-8", errors="replace") if isinstance(info["uid"], bytes) else str(info["uid"])
|
||||
mark_failed(uid_str)
|
||||
except Exception:
|
||||
pass
|
||||
mark_failed(uid_str)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if _running:
|
||||
_shutdown_event.wait(1)
|
||||
_shutdown_event.wait(0.2)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user