同步本地更改
This commit is contained in:
@@ -91,8 +91,18 @@ def compute_next_run_at(
|
||||
|
||||
if random_delay:
|
||||
window_start = candidate_base - timedelta(minutes=15)
|
||||
random_minutes = random.randint(0, 30)
|
||||
candidate = window_start + timedelta(minutes=random_minutes)
|
||||
window_end = candidate_base + timedelta(minutes=15)
|
||||
|
||||
# 只从“未来窗口”中抽样,避免抽到过去时间导致整天被跳过
|
||||
delta_seconds = (now - window_start).total_seconds()
|
||||
if delta_seconds < 0:
|
||||
min_offset = 0
|
||||
else:
|
||||
min_offset = int(delta_seconds // 60) + 1
|
||||
max_offset = int((window_end - window_start).total_seconds() // 60)
|
||||
if min_offset > max_offset:
|
||||
continue
|
||||
candidate = window_start + timedelta(minutes=random.randint(min_offset, max_offset))
|
||||
else:
|
||||
candidate = candidate_base
|
||||
|
||||
@@ -110,4 +120,3 @@ def format_cst(dt: datetime) -> str:
|
||||
dt = BEIJING_TZ.localize(dt)
|
||||
dt = dt.astimezone(BEIJING_TZ)
|
||||
return dt.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user