-
-
Save brantfaircloth/994727 to your computer and use it in GitHub Desktop.
# this works just fine w/ multiprocess... | |
# now with more flushing | |
import sys | |
import time | |
sys.stdout.write("This is running") | |
sys.stdout.flush() | |
for i in range(5): | |
sys.stdout.write(".") | |
sys.stdout.flush() | |
time.sleep(0.1) | |
sys.stdout.write("\nThis is running2") | |
sys.stdout.flush() | |
for i in range(10): | |
sys.stdout.write(".") | |
sys.stdout.flush() | |
time.sleep(0.1) | |
print "" |
The biggest problem with progressbar, in certain cases, is that i have to have some idea of the number of whatever it is that i'm processing. In the case of a 5 GB input file, computing the number of lines in the file is super slow (i,e. assuming we're processing line-by-line). I prefer the above in this case, because i really just want to know that something is still going on and get a rough visual indicator (e.g. one dot every 10k lines) of progress. Of course, there are any number of other, approximate, workarounds.
Otherwise, progressbar is actually "prettier".
edit: speelling
I use progressbar when I need to know the actual progress. otherwise, I sometimes use a spin cursor.
http://code.activestate.com/recipes/534142-spin-cursor/
then of course, flush a dot is always most effective.
ooh, i like this spin cursor - much more fancy-pants than my lowly dot flusher ; )
Cool. I ended up embedding progressbar.py in PyMC (http://code.google.com/p/python-progressbar/), because I'm lazy.