From 846c1a104ebd67cd7e014169a30796be4d2a105e Mon Sep 17 00:00:00 2001 From: yusing Date: Wed, 1 Jan 2025 06:16:33 +0800 Subject: [PATCH] small fix on task.finish --- internal/task/task.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/internal/task/task.go b/internal/task/task.go index 2ed1597..b431b18 100644 --- a/internal/task/task.go +++ b/internal/task/task.go @@ -93,14 +93,9 @@ func (t *Task) onCancel(about string, fn func(), waitSubTasks bool) { // Finish cancel all subtasks and wait for them to finish, // then marks the task as finished, with the given reason (if any). func (t *Task) Finish(reason any) { - select { - case <-t.finished: - return - default: - t.once.Do(func() { - t.finish(reason) - }) - } + t.once.Do(func() { + t.finish(reason) + }) } func (t *Task) finish(reason any) {