Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Added a stopping state for StopTask due to PANIC: close of closed cha…
Browse files Browse the repository at this point in the history
…nnel
  • Loading branch information
tiffanyfay committed Oct 27, 2015
1 parent 79007a0 commit 8c2533c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
TaskSpinning
TaskFiring
TaskEnded
TaskStopping
)

var (
Expand All @@ -46,6 +47,7 @@ var (
TaskSpinning: "Running", // running
TaskFiring: "Running", // running (firing can happen so briefly we don't want to try and render it as a string state)
TaskEnded: "Ended", // ended, not resumable because the schedule will not fire again
TaskStopping: "Stopping", // channel has been closed, wait for TaskStopped state
}
)

Expand Down
1 change: 1 addition & 0 deletions scheduler/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func (t *task) Stop() {
t.Lock()
defer t.Unlock()
if t.state == core.TaskFiring || t.state == core.TaskSpinning {
t.state = core.TaskStopping
close(t.killChan)
}
}
Expand Down

0 comments on commit 8c2533c

Please sign in to comment.