fix(executors): periodicalexecutor should handle crash correctly (#3043)

This commit is contained in:
cong
2023-03-18 23:04:15 +08:00
committed by GitHub
parent a561048d59
commit 18d163c4f7
2 changed files with 63 additions and 9 deletions

View File

@@ -116,7 +116,7 @@ func (pe *PeriodicalExecutor) addAndCheck(task any) (any, bool) {
}
func (pe *PeriodicalExecutor) backgroundFlush() {
threading.GoSafe(func() {
go func() {
// flush before quit goroutine to avoid missing tasks
defer pe.Flush()
@@ -144,7 +144,7 @@ func (pe *PeriodicalExecutor) backgroundFlush() {
}
}
}
})
}()
}
func (pe *PeriodicalExecutor) doneExecution() {
@@ -162,7 +162,9 @@ func (pe *PeriodicalExecutor) executeTasks(tasks any) bool {
ok := pe.hasTasks(tasks)
if ok {
pe.container.Execute(tasks)
threading.RunSafe(func() {
pe.container.Execute(tasks)
})
}
return ok