Hi all,
Referring to this topic https://community.temporal.io/t/use-case-of-sub-process-and-sample-logic-to-use/7034, if I use the workflow.go with awaitWithTimeout inside a loop, do I need to manually close them all? The code works, but when I go to Temporal Web UI → Stack Trace, I can see the go routines are still active. I have used context with cancel and called the cancel() method.
cancCtx, cancel := workflow.WithCancel(wfCtx)
cancel()
The cancelled activities will turn black:
Stack trace active go routine blocked, waiting for signal:



How do I close these go routines?
Also, if I have nested condition (go routine inside go routine), when I cancel the context to child process, does it automatically cancel the context for the grandchild process to?
> func processParent(wfCtx workflow.Context) {
> subProcessDone := false
> cancCtx, cancel := workflow.WithCancel(wfCtx)
> workflow.Go(cancCtx, func(gCtx workflow.Context) {
> processChild(gCtx)
> })
> ok, _ := workflow.AwaitWithTimeout(cancCtx, timer, func() bool {
> return subProcessDone
> })
> cancel()
> }
>
> func processChild(wfCtx workflow.Context) {
> subProcessDone := false
> cancCtx, cancel := workflow.WithCancel(wfCtx)
> workflow.Go(cancCtx, func(gCtx workflow.Context) {
> processAnotherChild(gCtx)
> })
> ok, _ := workflow.AwaitWithTimeout(cancCtx, timer, func() bool {
> return subProcessDone
> })
> cancel()
> }
>
> func processAnotherChild(wfCtx workflow.Context) {
> ...
> }