MCPcopy Create free account
hub / github.com/astercloud/aster / cleanupCompletedTasks

Method cleanupCompletedTasks

pkg/tools/builtin/task_manager.go:523–538  ·  view source on GitHub ↗

cleanupCompletedTasks 清理完成的任务

()

Source from the content-addressed store, hash-verified

521
522// cleanupCompletedTasks 清理完成的任务
523func (tm *FileTaskManager) cleanupCompletedTasks() {
524 tm.mu.Lock()
525 defer tm.mu.Unlock()
526
527 for _, task := range tm.tasks {
528 if task.Status == "completed" || task.Status == "failed" {
529 // 清理超过1小时的已完成任务
530 if time.Since(*task.EndTime) > time.Hour {
531 delete(tm.tasks, task.ID)
532
533 taskFile := filepath.Join(tm.dataDir, task.ID+".json")
534 _ = os.Remove(taskFile)
535 }
536 }
537 }
538}
539
540// getSignalNumber 获取信号编号
541func (tm *FileTaskManager) getSignalNumber(signal string) int {

Callers 1

cleanupRoutineMethod · 0.95

Calls 3

deleteFunction · 0.85
JoinMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected