From ec5a6b3a6edc32ba9c33cad65a6c2dd74104c46a Mon Sep 17 00:00:00 2001 From: Zhao vistart Date: Thu, 9 May 2024 14:31:52 +0800 Subject: [PATCH] try to solve #10 --- workflow/simple/dag.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/workflow/simple/dag.go b/workflow/simple/dag.go index 72a80d8..e2be770 100644 --- a/workflow/simple/dag.go +++ b/workflow/simple/dag.go @@ -285,10 +285,23 @@ func (d *Workflow[TInput, TOutput]) BuildWorkflowInput(ctx context.Context, resu for i := 0; i < len(inputs); i++ { i := i go func() { - if chs[i] != nil { - d.Log(ctx, LogEventChannelInputReady{LogEventChannelReady{value: result, name: inputs[i]}}) - chs[i] <- result + if chs[i] == nil { + return + } + for { + select { + case <-ctx.Done(): + return + case chs[i] <- result: + d.Log(ctx, LogEventChannelInputReady{LogEventChannelReady{value: result, name: inputs[i]}}) + return + default: + } } + //if chs[i] != nil { + // d.Log(ctx, LogEventChannelInputReady{LogEventChannelReady{value: result, name: inputs[i]}}) + // chs[i] <- result + //} }() } }