feat: 通用步骤支持概率触发、循环按时间、预计结束时间上报

- 步骤新增 probability 参数:<100 时按百分比概率决定是否执行(实现"偶尔点赞")
- loop 支持 loop_mode=rounds/time,按时间循环跑满 loop_duration 秒
- BaseWorker._start_timer 上报 end_time(开始+max_duration),task_manager 透出
This commit is contained in:
2026-08-08 16:30:54 +08:00
parent 4f29762121
commit fcbdb0a8a1
3 changed files with 33 additions and 7 deletions
+3
View File
@@ -246,6 +246,9 @@ class BaseWorker(threading.Thread):
def _start_timer(self):
"""子类在 run_task 开头调用,启动运行时长计时。"""
self._start_time = time.time()
if self.max_duration > 0:
# 预计结束时间(前端监控页展示),到点自动停止
_update_status(self.serial, end_time=self._start_time + self.max_duration)
def is_time_up(self):
"""是否已达最大运行时长。max_duration=0 时永远返回 False。"""
+1
View File
@@ -735,6 +735,7 @@ class TaskManager:
"running_job": r.get("job_id", ""),
"task_job": w.get("task_job", ""),
"attempt": r.get("attempt", 0),
"end_time": w.get("end_time", 0),
})
return result