From 18cd67a9ada11d07b917d7c8214351b9eb7d88ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 11 Aug 2023 16:47:21 +0800 Subject: [PATCH] update --- core.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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)) }