Codebase list golang-github-vbauerster-mpb / 6d950a4
refactoring: TestWithContext Vladimir Bauer 3 years ago
1 changed file(s) with 1 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
9898 ctx, cancel := context.WithCancel(context.Background())
9999 p := mpb.NewWithContext(ctx, mpb.WithShutdownNotifier(shutdown), mpb.WithOutput(io.Discard))
100100
101 done := make(chan struct{})
102101 bar := p.AddBar(0) // never complete bar
103102 go func() {
104103 for !bar.Aborted() {
105104 time.Sleep(randomDuration(100 * time.Millisecond))
106105 cancel()
107106 }
108 close(done)
109107 }()
110108
111 go func() {
112 <-done
113 p.Wait()
114 }()
109 go p.Wait()
115110
116111 select {
117112 case <-shutdown: