Skip to content

Conversation

lrq3000
Copy link
Member

@lrq3000 lrq3000 commented Jan 1, 2017

Continuation of #327 by @deeenes.

We now use status_printer() in clean() and refresh(), so not only this automatically does flush(), but it also saves the last print length, which will provide a more consistent display after executing clean() or refresh() and then displaying the bar again (I guess doing clean() and update() 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 using write() in various sceniarios, everything looks OK.

TODO:

  • Nothing.

deeenes and others added 2 commits January 1, 2017 20:59
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>
@lrq3000 lrq3000 added p2-bug-warning ⚠ Visual output bad to-merge ↰ Imminent labels Jan 1, 2017
@lrq3000 lrq3000 added this to the v5.0.0 milestone Jan 1, 2017
Copy link
Member

@casperdcl casperdcl left a 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('')
Copy link
Member

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?

Copy link
Member Author

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.

@lrq3000 lrq3000 added to-fix ⌛ In progress and removed to-merge ↰ Imminent labels Jan 12, 2017
@lrq3000
Copy link
Member Author

lrq3000 commented Jan 12, 2017

Just a quick update, please don't merge this one yet. I've investigated a bit and tried to use sp() everywhere instead of direct writing, but 2 test are now failing, the output being different, and it's not really obvious why. I guess the unreliability of sp('') is still true but I don't know why as it should work, I need to hunt down this bug some more!

@casperdcl
Copy link
Member

casperdcl commented Jan 13, 2017

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.

@DrJimFan
Copy link

Is this PR gonna be merged soon? I think it's the cause for #420 as well (in the latest 4.15 release).

@lrq3000
Copy link
Member Author

lrq3000 commented Sep 22, 2017

As an alternative to this PR, we could just use self.fp.flush(), this would basically have the same goal (without the weird side effects of self.sp('')).

@MPagel
Copy link
Contributor

MPagel commented Sep 22, 2017

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:

def flush(self):
        fp_flush = getattr(self.file, 'flush', lambda: None)
        fp_flush()

See also #439 #329 ab1bd78

casperdcl added a commit that referenced this pull request Sep 26, 2017
fixes #285 -> #291 -> #329
fixes #422
fixes #439

fixes #323
fixes #324
fixes #334
fixes #407
fixes #418

related to:
- #97
- #143
- #331
- #361
- #384
- #385
- #417
casperdcl added a commit that referenced this pull request Oct 5, 2017
@casperdcl
Copy link
Member

casperdcl commented Oct 5, 2017

could you try the devel branch to verify it fixes this issue? It's slightly different there.

@casperdcl casperdcl mentioned this pull request Oct 5, 2017
5 tasks
casperdcl added a commit that referenced this pull request Oct 5, 2017
@casperdcl casperdcl deleted the flush-fix branch May 3, 2021 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-bug-warning ⚠ Visual output bad to-fix ⌛ In progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants