Skip to content

Commit

Permalink
Merge pull request #886 from colinin/fix-tasks-with-remove-and-pause
Browse files Browse the repository at this point in the history
fix(tasks): Stops a job in execution upon deletion
  • Loading branch information
colinin authored Oct 2, 2023
2 parents f811f0d + 696a3e3 commit 07f2daa
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public async virtual Task PauseAsync(JobInfo job, CancellationToken cancellation
{
await Scheduler.PauseTrigger(trigger.Key, cancellationToken);
}

// 当暂停作业时, 需要停止已经在执行中的作业
await Scheduler.Interrupt(jobKey, cancellationToken);
}
}

Expand Down Expand Up @@ -114,6 +117,10 @@ public async virtual Task<bool> RemoveAsync(JobInfo job, CancellationToken cance
{
await Scheduler.PauseTrigger(trigger.Key, cancellationToken);
}

// 当删除作业时, 需要停止已经在执行中的作业
await Scheduler.Interrupt(jobKey, cancellationToken);

await Scheduler.DeleteJob(jobKey, cancellationToken);

return !await Scheduler.CheckExists(jobKey, cancellationToken);
Expand Down

0 comments on commit 07f2daa

Please sign in to comment.