Skip to content

Commit

Permalink
update after review
Browse files Browse the repository at this point in the history
Signed-off-by: lou <[email protected]>
  • Loading branch information
27149chen committed Feb 7, 2025
1 parent 996fdcb commit 1d366cb
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,20 @@ func (s *scheduler) stopScheduler() {
for _, j := range s.jobs {
j.stop()
}
for id, j := range s.jobs {
for _, j := range s.jobs {
<-j.ctx.Done()

}
var err error
if s.started {
t := time.NewTimer(s.exec.stopTimeout + 1*time.Second)
select {
case err = <-s.exec.done:
t.Stop()
case <-t.C:
err = ErrStopExecutorTimedOut
}
}
for id, j := range s.jobs {
oldCtx := j.ctx
if j.parentCtx == nil {
j.parentCtx = s.shutdownCtx
Expand All @@ -254,16 +265,7 @@ func (s *scheduler) stopScheduler() {

s.jobs[id] = j
}
var err error
if s.started {
t := time.NewTimer(s.exec.stopTimeout + 1*time.Second)
select {
case err = <-s.exec.done:
t.Stop()
case <-t.C:
err = ErrStopExecutorTimedOut
}
}

s.stopErrCh <- err
s.started = false
s.logger.Debug("gocron: scheduler stopped")
Expand Down

0 comments on commit 1d366cb

Please sign in to comment.