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
Do an automatic stream flush before rendering a progress bar #1177
Comments
interesting... is this consistently reproducible? |
Yes, every time. A flush always resolves. I found a similar observation about buffering from a few years back. spyder-ide/spyder#2860 I notice there's callback support in tqdm, but wasn't sure if tqdm itself has callbacks for the start, end and during processing. Given a start callback then a workaround might be to attach a function to flush, but a native feature would be ideal. |
does the current |
Sorry for the delayed feedback, and unfortunately not, a |
You mean |
I didn't realise that tqdm is using stderr, but would explain the issue as there are then two independently buffered streams both writing to the same destination. stderr is traditionally used for errors and if there's an option to use stdout instead that could be an alternative to flushing, but to be safe, I'd probably opt simply for tqdm to flush both stderr and stdout when starting a new progress tracker. |
can you try |
Thanks, the current devel version now resolves this. |
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 the1
was printed before the bar was started, the output was interleaved.An option to have tqdm automatically flush the output stream it's about to use would be a huge benefit.
The text was updated successfully, but these errors were encountered: