From 1118b099117531a51b7674b21382b9879fd4e783 Mon Sep 17 00:00:00 2001 From: Kevin Cheng Date: Wed, 23 Mar 2022 18:08:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DspareTime=20Cron=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=A4=B1=E8=B4=A5=E5=90=8E=E7=9A=84=E5=A4=84=E7=90=86?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Furion.Pure/TaskScheduler/SpareTime.cs | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/framework/Furion.Pure/TaskScheduler/SpareTime.cs b/framework/Furion.Pure/TaskScheduler/SpareTime.cs index bae2b09982..4905a7d064 100644 --- a/framework/Furion.Pure/TaskScheduler/SpareTime.cs +++ b/framework/Furion.Pure/TaskScheduler/SpareTime.cs @@ -231,6 +231,9 @@ public static class SpareTime // 执行方法 await doWhat(timer, currentRecord.CronActualTally); + // 只要执行成功一次,那么清空异常信息 + timer.Exception.Clear(); + // 执行后通知 await WriteChannel(timer, 2); @@ -333,22 +336,25 @@ public static class SpareTime // 执行任务 await doWhat(timer, currentRecord.Tally); - // 只要执行成功一次,那么清空异常信息 - currentRecord.Timer.Exception.Clear(); + if (timer.Type == SpareTimeTypes.Interval && !onlyInspect) + { + // 只要执行成功一次,那么清空异常信息 + currentRecord.Timer.Exception.Clear(); // 执行成功通知 - if (timer.Type == SpareTimeTypes.Interval && !onlyInspect) await WriteChannel(timer, 2); + await WriteChannel(timer, 2); + } } catch (Exception ex) { - // 执行异常通知 - if (timer.Type == SpareTimeTypes.Interval && !onlyInspect) await WriteChannel(timer, 3); - // 记录任务异常 - currentRecord.Timer.Exception.TryAdd(currentRecord.Tally, ex); + currentRecord.Timer.Exception.TryAdd(timer.Tally, ex); + + // 执行异常通知 + await WriteChannel(currentRecord.Timer, 3); - // 如果任务执行超过 10 次失败,则停止任务 - if (currentRecord.Timer.Exception.Count > 10) + // 如果任务执行连续 10 次失败,则停止任务 + if (currentRecord.Timer.Exception.Count >= 10) { Stop(workerName, true); } -- Gitee