-
-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WithSingletonMode(gocron.LimitModeWait) not queuing #676
Comments
I think this would be expected behaviour given your setup. `
}` And looking at LimitModeWait The cron string only lets us run jobs during seconds 1,2,3,4,5 & 7 therefore these are our 6 "slots", If we have one running we will queue it. Lets name the seconds Job1-Job7
I could be wrong though |
Would you be willing to validate the release candidate solves the issue? v2.2.5-rc1 Testing it locally, it does now run your job 6 times, and they will just be spread out depending on how much time you sleep. For example with a 2s sleep per run: package main
import (
"fmt"
"log"
"time"
"github.com/go-co-op/gocron/v2"
)
func main() {
scheduler, err := gocron.NewScheduler(
gocron.WithGlobalJobOptions(
gocron.WithSingletonMode(gocron.LimitModeWait),
))
if err != nil {
fmt.Println("Failed to create new scheduler")
fmt.Print(err)
return
}
scheduler.NewJob(
gocron.CronJob("1,2,3,4,5,7 * * * * *", true),
gocron.NewTask(Callback),
)
scheduler.Start()
select {
// do something here to handle stopping your app
}
}
func Callback() {
log.Println("A")
time.Sleep(2 * time.Second)
log.Println("B")
} Output:
|
Describe the bug
WithSingletonMode(gocron.LimitModeWait)
not queuing overlapping tasks, skipping insteadTo Reproduce
Ran in VSCode
Output only 3 runs occurred:
Version
v2
387cbe4
Expected behavior
A total of 6 runs of
Callback
to occur, although delayed from their start time due to the length of executionThe text was updated successfully, but these errors were encountered: