Skip to content

Manually flushing leaves progress bars in the output #159

Description

@davidparsson

Description

Manually flushing leaves progress bars in the output. Please see the following example:

Code

import time
import progressbar


with progressbar.ProgressBar(redirect_stdout=True) as progress:
    for i in progress(range(3)):
        for j in range(3):
            time.sleep(1)
            print(i, j)
            progressbar.streams.flush()

Output

N/A% (0 of 100) |                        | Elapsed Time: 0:00:00 ETA:  --:--:--0 0
0 1
0 2
 66% (2 of 3) |##################         | Elapsed Time: 0:00:03 ETA:  0:00:011 0
1 1
1 2
100% (3 of 3) |###########################| Elapsed Time: 0:00:06 ETA:  0:00:002 0
2 1
2 2
100% (3 of 3) |###########################| Elapsed Time: 0:00:09 Time: 0:00:09
100% (3 of 3) |###########################| Elapsed Time: 0:00:09 Time: 0:00:09

Versions

  • Python version: 3.6.2
  • Python distribution/environment: CPython
  • Operating System: MacOS
  • Package version: 3.36.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