Skip to content

Commit

Permalink
fix go routine scope
Browse files Browse the repository at this point in the history
  • Loading branch information
nohaapav committed Jun 6, 2018
1 parent 9668328 commit adff5c7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions swarmpit/task/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,15 @@ func ContainersUsage(cli *client.Client) (stats []ContainerStatus) {
mux := &sync.Mutex{}

for _, v := range resp {
go func() {
go func(v types.Container) {
defer wg.Done()
var stat = ContainerUsage(cli, v.ID);
mux.Lock()
stats = append(stats, stat)
mux.Unlock()
}()
}(v)
}

wg.Wait()
return
}
Expand Down

0 comments on commit adff5c7

Please sign in to comment.