Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[progress] corner case: overall tracker disappears #245

Closed
iyear opened this issue Nov 27, 2022 · 1 comment · Fixed by #246
Closed

[progress] corner case: overall tracker disappears #245

iyear opened this issue Nov 27, 2022 · 1 comment · Fixed by #246

Comments

@iyear
Copy link
Contributor

iyear commented Nov 27, 2022

Describe the bug
When Progress.updateFrequency and tracker completion time are both small and similar(especially equal), the overall tracker may disappears.

The reason for this (maybe): the overall tracker is determined to be done before the tracker is appended, but the tracker is successfully appended before the next render. Progress continues to run, but the overall tracker will never appear again.

In short: overall tracker is done, but new tracker is being added.

To Reproduce

package main

import (
	"fmt"
	"github.com/jedib0t/go-pretty/v6/progress"
	"strconv"
	"time"
)

func main() {
	pw := progress.NewWriter()
	pw.SetTrackerPosition(progress.PositionRight)
	pw.SetUpdateFrequency(time.Millisecond * 100)
	pw.Style().Colors = progress.StyleColorsExample
	pw.Style().Visibility.TrackerOverall = true

	go pw.Render()

	sem := make(chan struct{}, 3)

	for i := 0; i < 1000; i++ {
		sem <- struct{}{}
		go func(n int) {
			tracker := progress.Tracker{Message: strconv.Itoa(n)}
			pw.AppendTracker(&tracker)
			time.Sleep(100 * time.Millisecond)
			tracker.MarkAsDone()
			<-sem
		}(i)
	}

}

Expected behavior
Overall tracker will still run in the case.

Software (please complete the following information):

  • OS: windows
  • GoLang Version: 1.19
@jedib0t
Copy link
Owner

jedib0t commented Nov 28, 2022

Cut a tag for you with the fix: https://github.com/jedib0t/go-pretty/releases/tag/v6.4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants