task package: replace waitgroup with channel, fix stuck

This commit is contained in:
yusing
2025-01-02 11:12:13 +08:00
parent af14966b09
commit 2fe0b888bd
5 changed files with 152 additions and 102 deletions

View File

@@ -10,7 +10,7 @@ import (
)
func testTask() *Task {
return RootTask("test", false)
return RootTask("test", true)
}
func TestChildTaskCancellation(t *testing.T) {
@@ -34,7 +34,7 @@ func TestChildTaskCancellation(t *testing.T) {
parent.cancel(nil) // should also cancel child
select {
case <-child.Finished():
case <-child.Context().Done():
ExpectError(t, context.Canceled, child.Context().Err())
default:
t.Fatal("subTask context was not canceled as expected")