-
-
Notifications
You must be signed in to change notification settings - Fork 211
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 'isatty' (progress.py, line 163) #17
Comments
Hello @jonturneratduke That's weird, it does work on Python 3.7:
|
Ohh I see, you are using the Python provided by the system? I'll try to find out if the MacOS one have something different. |
running Python v3.7.5. I saw this behavior with v1.1 and the latest v1.3 of alive-progress. I'll see if I can use pyenv, it gets complicated with our build system and packaging(using pyinstaller) on a remote gitlab runner... |
Although I'm not sure of the reason for the sys.stdout.isatty() being null, this at least safely checks the condition without throwing an exception. progress.py @ line 163
edit: refer to isatty() method. And in the code, call it if it's available. |
But the error does not say null anywhere, it says the attribute I do install a hook in stdout at some point, but this line should have already ran... Could you please post the complete stacktrace? Maybe there's something more there. |
You're correct. Sorry for my lack of precision. The isatty method/attribute reference is null, not the parent object.
So to explain what's going on, azureUtils.py is calling Azure's download method ane passing a reference to a callback. Azure's library thread calls that callback, which creates your progressbar, and the callback periodically updates the bar's status. |
@rogerio-geru any thoughts on whether the code above (#17 (comment)) would be a suitable patch? |
Hello @jonturneratduke I did understand what did happen, it should not be needed. So, after being used, your I can simulate by doing manually this: In [1]: from alive_progress import alive_bar
In [2]: pb = alive_bar()
In [3]: pb.__enter__()
on 0: <function alive_progress.progress.alive_bar.<locals>.bar(text=None, incr=1)>
on 0:
In [4]:
on 0:
In [4]: pb2 = alive_bar()
on 0:
In [5]: pb2.__enter__()
on 0: ---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-5-11d9d01a04a1> in <module>
----> 1 pb2.__enter__()
~/.pyenv/versions/3.7.4/lib/python3.7/contextlib.py in __enter__(self)
110 del self.args, self.kwds, self.func
111 try:
--> 112 return next(self.gen)
113 except StopIteration:
114 raise RuntimeError("generator didn't yield") from None
~/.pyenv/versions/3.7.4/envs/segregation/lib/python3.7/site-packages/alive_progress/progress.py in alive_bar(total, title, calibrate, **options)
161
162 event = threading.Event()
--> 163 if sys.stdout.isatty() or config.force_tty:
164 @contextmanager
165 def pause_monitoring():
AttributeError: 'function' object has no attribute 'isatty'
on 0:
| ▶▶▶▶▶▶▶▶▶▶▶▶▶ | ▃▁▃ 0 in 40s (0.0/s) (0.0/s) |
Well, I think I can proxy the isatty method inside my print hook, no problem. |
Related to #20 |
Fixed in 1.3.3, please let me know if that's ok. |
The library is throwing the following exception w. MacOS High Sierra 10.13.6 (17G8030):
The text was updated successfully, but these errors were encountered: