Skip to content

Instantly share code, notes, and snippets.

@Gautier
Created May 28, 2012 07:21
Show Gist options
  • Save Gautier/2817837 to your computer and use it in GitHub Desktop.
Save Gautier/2817837 to your computer and use it in GitHub Desktop.
""" from Paul Moore at
http://code.activestate.com/recipes/535141-console-progress-dots-using-threads-and-a-context-/ copied here as a bookmark"""
import sys
import threading
class Ticker(threading.Thread):
def __init__(self, msg):
threading.Thread.__init__(self)
self.msg = msg
self.event = threading.Event()
def __enter__(self):
self.start()
def __exit__(self, ex_type, ex_value, ex_traceback):
self.event.set()
self.join()
def run(self):
sys.stdout.write(self.msg)
while not self.event.isSet():
sys.stdout.write(".")
sys.stdout.flush()
self.event.wait(1)
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment