mirror of https://github.com/go-co-op/gocron.git
fix: cleanup timers (#776)
* fix: cleanup timers * chore: bring comments back
This commit is contained in:
parent
c84d8f70c4
commit
40b8570e23
|
|
@ -359,6 +359,13 @@ func (s *scheduler) selectExecJobsOutForRescheduling(id uuid.UUID) {
|
|||
next = j.next(next)
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up any existing timer to prevent leaks
|
||||
if j.timer != nil {
|
||||
j.timer.Stop()
|
||||
j.timer = nil // Ensure timer is cleared for GC
|
||||
}
|
||||
|
||||
j.nextScheduled = append(j.nextScheduled, next)
|
||||
j.timer = s.exec.clock.AfterFunc(next.Sub(s.now()), func() {
|
||||
// set the actual timer on the job here and listen for
|
||||
|
|
|
|||
Loading…
Reference in New Issue