Skip to content

Progressbar as wrapped iterable gets out of sync #121

Description

@tobiasmaier

Description

Progressbar as wrapped iterable show to high ETA if iterations take less than _MINIMUM_UPDATE_INTERVAL.

The example code from the documentation jumps from

38% (38 of 100) |######### | Elapsed Time: 0:00:01 ETA: 0:00:03

to

100% (100 of 100) |#######################| Elapsed Time: 0:00:02 Time: 0:00:02

The reason is that the wrapper around the iterable calls self.update(self.value + 1) but self.value is not updated if the time from last update is less than _MINIMUM_UPDATE_INTERVAL.

Code

Just added print statement to example code from documentation to show the mismatch between internal value and actual iteration.

import time
import progressbar

bar = progressbar.ProgressBar()
for i in bar(range(100)):
    print(i, bar.value)
    time.sleep(0.02)

Versions

  • Python version: 3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 5.4.0 20160609]
  • Python distribution/environment: CPython
  • Operating System: Ubuntu Linux
  • Package version: 3.20.0

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