diff --git a/core.go b/core.go index 143fb9b..049bdfd 100644 --- a/core.go +++ b/core.go @@ -92,9 +92,23 @@ func (tw *TimeWheel) checkAndRunTask() { // 执行任务时,Task.job是第一优先级,然后是TimeWheel.job if task.Job != nil { - go task.Job.Execute(nil, nil) + go func() { + defer func() { + if r := recover(); nil != r { + + } + }() + _, _ = task.Job.Execute(nil, nil) + }() } else if tw.Job != nil { - go tw.Job.Execute(nil, nil) + go func() { + defer func() { + if r := recover(); nil != r { + + } + }() + _, _ = tw.Job.Execute(nil, nil) + }() } else { fmt.Println(fmt.Sprintf("The task %v don't have job to run", task.Key)) }