Bladeren bron

feat(protector): 记录循环启动时的最后运行时间

- 在循环启动时设置 last_run_time 以便外部调用者可预测地计算下次运行时间
- 添加异常处理以确保时间记录不会中断启动过程
- 更新时间记录逻辑以提高运行时间计算的准确性
mcbaiyun 2 maanden geleden
bovenliggende
commit
bec5653d3e
1 gewijzigde bestanden met toevoegingen van 6 en 0 verwijderingen
  1. 6 0
      protector.py

+ 6 - 0
protector.py

@@ -79,6 +79,12 @@ class ProtectorRunner:
 
     def start(self):
         self._stop.clear()
+        # mark last_run_time when loop is started so external callers can compute
+        # next run time predictably (will be updated when run_once actually runs)
+        try:
+            self.last_run_time = time.time()
+        except Exception:
+            pass
         def _loop():
             while not self._stop.is_set():
                 # respect pause state