You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you start a scheduler with a job that says run every second, everything will work fine. If you stop the scheduler and then start the scheduler again without removing or adding jobs, the existing job will run twice. If you stop and restart the scheduler again, it will run the job three times every second and so on and so forth.
To Reproduce
package main
import (
"fmt""time""github.com/go-co-op/gocron"
)
vartask=func() {
fmt.Println(time.Now())
}
funcmain() {
vars*gocron.Scheduler=gocron.NewScheduler(time.UTC)
fmt.Println("Adding job to cron and starting for 5 seconds")
job, _:=s.Every(1).Seconds().Do(task)
s.StartAsync()
time.Sleep(5*time.Second)
fmt.Println("Stopping and sleeping for 5 seconds")
s.Stop()
fmt.Printf("Job run count: %v\n", job.RunCount())
time.Sleep(5*time.Second)
fmt.Println("Starting and sleeping for 10 seconds")
s.StartAsync()
time.Sleep(10*time.Second)
fmt.Printf("Job run count: %v\n", job.RunCount())
}
Expected to have a job run count about 14-16 after running the above test script. Stopping and then restarting a scheduler should continue to only run a specific job once per set interval.
The text was updated successfully, but these errors were encountered:
Describe the bug
If you start a scheduler with a job that says run every second, everything will work fine. If you stop the scheduler and then start the scheduler again without removing or adding jobs, the existing job will run twice. If you stop and restart the scheduler again, it will run the job three times every second and so on and so forth.
To Reproduce
Output:
Version
Tested on v1.6.2 and the latest v1.16.1
Expected behavior
Expected to have a job run count about 14-16 after running the above test script. Stopping and then restarting a scheduler should continue to only run a specific job once per set interval.
The text was updated successfully, but these errors were encountered: