gocron
gocron copied to clipboard
[BUG] - OneTimeJob Missing Execution
Describe the bug
It is not executing according to LimitModeWait mode, but rather behaving like LimitModeReschedule.
To Reproduce
Steps to reproduce the behavior:
func main() {
s, _ := gocron.NewScheduler(gocron.WithLimitConcurrentJobs(10, gocron.LimitModeWait))
s.Start()
fmt.Println("begin", time.Now().Format("2006-01-02 15:04:05"))
_, _ = s.NewJob(
gocron.OneTimeJob(gocron.OneTimeJobStartDateTimes(time.Now().Add(3*time.Second), time.Now().Add(6*time.Second), time.Now().Add(15*time.Second))),
gocron.NewTask(
func() error {
fmt.Println("Run time:", time.Now().Format("2006-01-02 15:04:05"))
time.Sleep(10 * time.Second)
return nil
},
),
gocron.WithSingletonMode(gocron.LimitModeWait),
)
select {
case <-time.After(15 * time.Minute):
}
}
Execution Results:
begin 2024-09-07 15:26:27
Run time: 2024-09-07 15:26:30
Run time: 2024-09-07 15:26:42
time.Now().Add(6*time.Second) not running If you delete gocron.WithLimitConcurrentJobs(10, gocron.LimitModeWait) or set gocron.WithLimitConcurrentJobs(1, gocron.LimitModeWait) , job all will run
Version
v2.11.0