Function is called but after that func's execution is not started


(Taalhach) #1

i have a code like this

func  outerFunc (wg *sync.WaitGroup,arr []inteface){
        defer wg.done
	for i, data := range arr {
           innerfunc(data)
        }
}

func  innerfunc (data inteface){
     // do processing to data 
    debug.PrintStack()
 }


func main(){
var wg sync.WaitGroup
data:= "some data"
for {
      <-time.After(10* time.Second)
      wg.Add(1)
      outerFunc(&wg,data)
   }
}

outerFunc calls innerFunc and prints and complete all of its execution in first iteration but when i call outerFunc in second iteration it get stuck at innerFunc(data) and func y’s printstack isn’t called which means innerfunc never executed and program is stuck at that point no exception and warning is thrown. is there anything i am doing ?
Note: this function is running in docker container.


(Norbert Melzer) #2

Can you prepare a version on the playground, as this version contains typos from which I’m unsure if they were there and part of the problem or only introduced when copying the code to the forum.


(Taalhach) #3

https://play.golang.org/p/diIS6j46kCV
this is sample of the func but in real func is same but with some complexities