gen-manifests: don't print progress when nothing changed
Update the progress line only when another line was received, which in this case means a job has started or finished. No need to keep reprinting the progress.
This commit is contained in:
parent
6e4a55cf9e
commit
d61b553045
1 changed files with 6 additions and 16 deletions
|
|
@ -5,7 +5,6 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
type workerQueue struct {
|
||||
|
|
@ -94,22 +93,13 @@ func (wq *workerQueue) startMessagePrinter() {
|
|||
go func() {
|
||||
defer wq.utilWG.Done()
|
||||
var msglen int
|
||||
for {
|
||||
select {
|
||||
case msg, open := <-wq.msgQueue:
|
||||
// clear previous line (avoids leftover trailing characters from progress)
|
||||
fmt.Printf(strings.Repeat(" ", msglen) + "\r")
|
||||
if !open {
|
||||
fmt.Println()
|
||||
return
|
||||
}
|
||||
fmt.Println(msg)
|
||||
default:
|
||||
msglen, _ = fmt.Printf(" == Jobs == Queue: %4d Active: %4d Total: %4d\r", len(wq.jobQueue), wq.activeWorkers, wq.njobs)
|
||||
// sleep a bit when printing progress to avoid constantly pushing out the same progress message
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
for msg := range wq.msgQueue {
|
||||
// clear previous line (avoids leftover trailing characters from progress)
|
||||
fmt.Printf(strings.Repeat(" ", msglen) + "\r")
|
||||
fmt.Println(msg)
|
||||
msglen, _ = fmt.Printf(" == Jobs == Queue: %4d Active: %4d Total: %4d\r", len(wq.jobQueue), wq.activeWorkers, wq.njobs)
|
||||
}
|
||||
fmt.Println()
|
||||
}()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue