Skip to content

[progress] corner case: overall tracker disappears #245

Closed
@iyear

Description

@iyear

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions