Skip to content

Commit

Permalink
fix: send on closed channel
Browse files Browse the repository at this point in the history
  • Loading branch information
WangYihang committed Jan 17, 2024
1 parent 9c7769f commit 042d340
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gojob.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,14 @@ func (s *Scheduler) Wait() {
// Worker is a worker
func (s *Scheduler) Worker() {
for task := range s.TaskChan {

// do task
err := task.Do()
// check if retry is needed
if err != nil && task.NeedRetry() {
go s.Submit(task)
s.taskWg.Add(1)
go func() {
s.TaskChan <- task
}()
}
// put log to log channel
data, err := task.Bytes()
Expand Down

0 comments on commit 042d340

Please sign in to comment.