Skip to content
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

AttributeError: 'function' object has no attribute 'flush' #2

Closed
jhmenke opened this issue Aug 7, 2019 · 9 comments
Closed

AttributeError: 'function' object has no attribute 'flush' #2

jhmenke opened this issue Aug 7, 2019 · 9 comments

Comments

@jhmenke
Copy link

jhmenke commented Aug 7, 2019

I am trying a simple example to replace tqdm with the alive_bar
with alive_bar(int(self.ann_params["epochs"])) as pbar:

Unfortunately, this line raises an Exeption:

Exception ignored in: <function alive_bar at 0x7fefe58f6ae8>
AttributeError: 'function' object has no attribute 'flush'```

I am using Python 3.7.3 on elementaryOS (Ubuntu derivative). Am i doing something wrong?
@jonturneratduke
Copy link

If my experience on MacOS is any guide, you're sending some output to the console which interferes with alive_bar's call to sys.stdout.flush().

@rsalmei
Copy link
Owner

rsalmei commented Aug 8, 2019

Hey @jhmenke, I'm using 3.7.3 myself and this error is not triggered.
Could you help me debugging this?
I didn't try it on ubuntu (or any derivatives actually), but should work.
Is this Python CPython?

Actually, I did try on Ubuntu 18.04, Python 3.7.3 and 2.7.15, installed with pyenv, and it works.

@rsalmei
Copy link
Owner

rsalmei commented Aug 8, 2019

I was looking into Python Streams (https://docs.python.org/2.7/library/io.html#module-io), and really there are other methods a stream should have.

Are your code by any chance calling flush() directly?

@jhmenke
Copy link
Author

jhmenke commented Aug 8, 2019

Okay, so it works in the regular terminal.

I was using PyCharm and i guess that somehow has a different terminal which does not work. Interestingly, tqdm works just fine so i guess something has to be checked and done differently.

Thanks for your comments though!

This is related for tqdm: tqdm/tqdm#307 (comment)

@rogerio-geru
Copy link

No problem!

I can release a version with flush support, maybe it would work.
Anyway, I was not aware of this pycharm terminal problem. I'll try it there and report back.

@rogerio-geru
Copy link

rogerio-geru commented Aug 8, 2019

Great news @jhmenke, I've made it work in Pycharm! At least in the latest 2019.2 it did work.
Tonight I'll release the 1.0.1 version with pycharm support.

It's curious I did not have the flush error you reported.
I'll let you know when it's available, and please tell me if it does work for you.

@rsalmei
Copy link
Owner

rsalmei commented Aug 9, 2019

Fixed and released in #5.
Could you please confirm it does work for you now? @jhmenke

Repository owner deleted a comment from rogerio-geru Aug 9, 2019
@jhmenke
Copy link
Author

jhmenke commented Aug 9, 2019

With force_tty=True it works in PyCharm, great!

Thank you so much for your time.

@jhmenke jhmenke closed this as completed Aug 9, 2019
@rsalmei
Copy link
Owner

rsalmei commented Aug 9, 2019

You're welcome. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants