Skip to content

Do an automatic stream flush before rendering a progress bar #1177

@nickion

Description

@nickion

4.60.0 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] win32
Running Python in Spyder

While tqdm is great for the negligible effort required to have a progress bar, I've found it necessary to add a sys.stdout.flush() call before usage to avoid possible interleaved output. This taints the code and reduces the ease of use. e.g. below, where although the 1 was printed before the bar was started, the output was interleaved.

1%|          | 14/2408 [00:00<00:17, 135.41it/s]1
11%|█         | 263/2408 [00:02<00:17, 123.80it/s]

An option to have tqdm automatically flush the output stream it's about to use would be a huge benefit.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions