We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
(*Scheduler).Stop func should wait for all jobs to finish due to its doc, but it possibly returns before all jobs finished.
(This is a concurrent issue and a bit hard to reproduce)
Add time.Sleep(time.Second) after the lines below (to raise the concurrent issue on purpose)
time.Sleep(time.Second)
gocron/executor.go
Lines 47 to 48 in e315112
Write some code like this:
func main() { s := gocron.NewScheduler(time.UTC) s.Every(1).Second().Do(func() { fmt.Println("Job started") time.Sleep(5 * time.Second) fmt.Println("Job finished") }) go func() { time.Sleep(3 * time.Second) fmt.Println("Trying to stop") s.Stop() fmt.Println("Stopped") }() s.StartAsync() time.Sleep(10 * time.Second) }
The output on my machine is:
Job started Job started Trying to stop Stopped Job started Job finished Job finished Job finished
As we can see, Stop() func returns before the jobs finished. Expected behavior is that Stopped log is shown at the end.
Stop()
Stopped
latest main: e315112
Stop() func always waits for the jobs to finish.
N/A
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Describe the bug
(*Scheduler).Stop func should wait for all jobs to finish due to its doc, but it possibly returns before all jobs finished.
To Reproduce
(This is a concurrent issue and a bit hard to reproduce)
Add
time.Sleep(time.Second)
after the lines below (to raise the concurrent issue on purpose)gocron/executor.go
Lines 47 to 48 in e315112
Write some code like this:
The output on my machine is:
As we can see,
Stop()
func returns before the jobs finished. Expected behavior is thatStopped
log is shown at the end.Version
latest main: e315112
Expected behavior
Stop()
func always waits for the jobs to finish.Additional context
N/A
The text was updated successfully, but these errors were encountered: