-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix flush() in clean() and refresh() #331
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
Conversation
without `self.fp.flush()`, refresh always fails in Python 3.5 (but not in 2.7), even with the most mimal test code. added `flush` at the end of `refresh`.
Signed-off-by: Stephen L. <lrq3000@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me provided the comment is addressed.
@@ -1049,8 +1049,7 @@ def clear(self, nomove=False): | |||
if not nomove: | |||
self.moveto(self.pos) | |||
# clear up the bar (can't rely on sp('')) | |||
self.fp.write('\r') | |||
self.fp.write(' ' * (self.ncols if self.ncols else 10)) | |||
self.sp('') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is L1052 sufficient despite the warning on L1051?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I totally missed the comment! All the unit tests pass fine and my own test scripts too, so I don't know nor remember at all why sp couldn't be relied on. I'm going to use git blame and git pickaxe to trace back this comment and see whether I can get more info.
Just a quick update, please don't merge this one yet. I've investigated a bit and tried to use |
Thanks. I recall writing this code a long time ago and there was a good reason. I think. Which was why I asked. It's better if you take a look at it for a second opinion. |
6ec00f1
to
4b6476a
Compare
Is this PR gonna be merged soon? I think it's the cause for #420 as well (in the latest 4.15 release). |
As an alternative to this PR, we could just use |
I tried self.fp.flush() first, but that didn't seem to work in a multithreading environment (eventlet) where I was catching all output to stdout/err as per documentation. The following seems to work:
|
could you try the |
Continuation of #327 by @deeenes.
We now use
status_printer()
inclean()
andrefresh()
, so not only this automatically doesflush()
, but it also saves the last print length, which will provide a more consistent display after executingclean()
orrefresh()
and then displaying the bar again (I guess doingclean()
andupdate()
in this order might produce weird displays sometimes, this should be fixed by this PR).Just one test for
write()
had to be adapted, I checked myself with old example scripts usingwrite()
in various sceniarios, everything looks OK.TODO: