Skip to content

Instantly share code, notes, and snippets.

@brantfaircloth
Created May 27, 2011 06:02
Show Gist options
  • Save brantfaircloth/994727 to your computer and use it in GitHub Desktop.
Save brantfaircloth/994727 to your computer and use it in GitHub Desktop.
pretty easy progress indicator
# 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 ""
@fonnesbeck
Copy link

Cool. I ended up embedding progressbar.py in PyMC (http://code.google.com/p/python-progressbar/), because I'm lazy.

@brantfaircloth
Copy link
Author

brantfaircloth commented May 27, 2011 via email

@brantfaircloth
Copy link
Author

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

@tanghaibao
Copy link

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.

@brantfaircloth
Copy link
Author

ooh, i like this spin cursor - much more fancy-pants than my lowly dot flusher ; )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment