Created
May 28, 2012 07:21
-
-
Save Gautier/2817837 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" 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) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment