From be961c6af6c1fdfa4a00b75234d61e703c749eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=A5=E5=BE=AE?= Date: Mon, 13 Jul 2026 11:17:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=5Fpush=5Fcooldown=E6=8C=81=E4=B9=85?= =?UTF-8?q?=E5=8C=96=E5=88=B0=E6=96=87=E4=BB=B6=EF=BC=8C=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E6=AF=8F2=E5=88=86=E9=92=9F=E9=87=8D=E5=A4=8D=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E6=93=8D=E4=BD=9C=E5=8C=BA=E9=97=B4=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/price_monitor.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/price_monitor.py b/scripts/price_monitor.py index 7c9a4a88..a2dcb491 100644 --- a/scripts/price_monitor.py +++ b/scripts/price_monitor.py @@ -333,6 +333,15 @@ def run_once(round_label=""): state_updated = False # 时间冷却:同股同区间30分钟内不重复推 _push_cooldown = {} + _cooldown_file = "/home/hmo/.hermes/.price_push_cooldown.json" + try: + import os + if os.path.exists(_cooldown_file): + with open(_cooldown_file) as _f: + _push_cooldown = json.load(_f) + except Exception: + _push_cooldown = {} + def _can_push(code, zone_key): now = time.time() key = f"{code}_{zone_key}" @@ -340,6 +349,12 @@ def run_once(round_label=""): if now - last < 1800: # 30分钟 return False _push_cooldown[key] = now + # 持久化写入 + try: + with open(_cooldown_file, "w") as _f: + json.dump(_push_cooldown, _f) + except Exception: + pass return True # 收集所有需要检查的代码