fix: process one queued email per poll cycle to keep callbacks responsive
This commit is contained in:
6
main.py
6
main.py
@@ -107,14 +107,14 @@ def _tg_worker(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)
|
||||||
|
|
||||||
while _running:
|
# 每轮只处理一封待发邮件,然后立刻回去 poll Telegram
|
||||||
try:
|
try:
|
||||||
info = _tg_queue.get_nowait()
|
info = _tg_queue.get_nowait()
|
||||||
tg_send_and_mark(cfg, info)
|
tg_send_and_mark(cfg, info)
|
||||||
uid_str = info["uid"].decode("utf-8", errors="replace") if isinstance(info["uid"], bytes) else str(info["uid"])
|
uid_str = info["uid"].decode("utf-8", errors="replace") if isinstance(info["uid"], bytes) else str(info["uid"])
|
||||||
mark_sent(uid_str)
|
mark_sent(uid_str)
|
||||||
except queue_module.Empty:
|
except queue_module.Empty:
|
||||||
break
|
pass
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"TG 发送失败: {e}", exc_info=True)
|
logger.error(f"TG 发送失败: {e}", exc_info=True)
|
||||||
try:
|
try:
|
||||||
@@ -124,7 +124,7 @@ def _tg_worker(cfg):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if _running:
|
if _running:
|
||||||
_shutdown_event.wait(1)
|
_shutdown_event.wait(0.2)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Reference in New Issue
Block a user