const timeout
Vladimir Bauer
4 years ago
| 8 | 8 | |
| 9 | 9 | "github.com/vbauerster/mpb/v7" |
| 10 | 10 | "github.com/vbauerster/mpb/v7/decor" |
| 11 | ) | |
| 12 | ||
| 13 | const ( | |
| 14 | timeout = 200 * time.Millisecond | |
| 11 | 15 | ) |
| 12 | 16 | |
| 13 | 17 | func init() { |
| 39 | 43 | go p.Wait() |
| 40 | 44 | select { |
| 41 | 45 | case <-shutdown: |
| 42 | case <-time.After(150 * time.Millisecond): | |
| 43 | t.Error("Progress didn't shutdown") | |
| 46 | case <-time.After(timeout): | |
| 47 | t.Errorf("Progress didn't shutdown after %v", timeout) | |
| 44 | 48 | } |
| 45 | 49 | } |
| 46 | 50 | |
| 84 | 88 | go p.Wait() |
| 85 | 89 | select { |
| 86 | 90 | case <-shutdown: |
| 87 | case <-time.After(150 * time.Millisecond): | |
| 88 | t.Error("Progress didn't shutdown") | |
| 91 | case <-time.After(timeout): | |
| 92 | t.Errorf("Progress didn't shutdown after %v", timeout) | |
| 89 | 93 | } |
| 90 | 94 | } |
| 91 | 95 | |
| 109 | 113 | select { |
| 110 | 114 | case <-done: |
| 111 | 115 | p.Wait() |
| 112 | case <-time.After(150 * time.Millisecond): | |
| 116 | case <-time.After(timeout): | |
| 113 | 117 | close(fail) |
| 114 | 118 | } |
| 115 | 119 | }() |
| 117 | 121 | select { |
| 118 | 122 | case <-shutdown: |
| 119 | 123 | case <-fail: |
| 120 | t.Error("Progress didn't shutdown") | |
| 124 | t.Errorf("Progress didn't shutdown after %v", timeout) | |
| 121 | 125 | } |
| 122 | 126 | } |
| 123 | 127 | |