feat: 通用步骤支持概率触发、循环按时间、预计结束时间上报
- 步骤新增 probability 参数:<100 时按百分比概率决定是否执行(实现"偶尔点赞") - loop 支持 loop_mode=rounds/time,按时间循环跑满 loop_duration 秒 - BaseWorker._start_timer 上报 end_time(开始+max_duration),task_manager 透出
This commit is contained in:
@@ -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。"""
|
||||
|
||||
Reference in New Issue
Block a user