Skip to content

Commit 0b80ab2

Browse files
committed
🐛 fix(interval): 修复间隔动作的初始执行
- 调整间隔动作的判断逻辑,确保在 `last_time` 为负时立即触发 - 将 `reset` 函数中的 `last_time` 初始值从 `0` 改为 `-1` - 解决在某些情况下,重置后动作可能不会立即执行的问题
1 parent ed4e8a5 commit 0b80ab2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/tasks/BaseDNATask.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,13 @@ def tick():
427427
multiplier = random.uniform(interval_random_range[0], interval_random_range[1])
428428
current_interval = get_interval() * multiplier
429429

430-
if now - last_time >= current_interval:
430+
if last_time < 0 or now - last_time >= current_interval:
431431
last_time = now
432432
action()
433433

434434
def reset():
435435
nonlocal last_time
436-
last_time = 0
436+
last_time = -1
437437

438438
def touch():
439439
nonlocal last_time

0 commit comments

Comments
 (0)