Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
30 lines (24 sloc)
586 Bytes
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
import threading | |
import time | |
import datetime | |
import sys | |
def log(s): | |
t = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') | |
sys.stdout.write('[%s] %s\n' % (t, s)) | |
sys.stdout.flush() | |
def loop(): | |
log('Started SampleWorker(python version), press enter to exit') | |
while running: | |
log('Running') | |
time.sleep(1) | |
log('Stopped SampleWorker(python version)') | |
running = True | |
th = threading.Thread(target=loop) | |
th.start() | |
try: | |
msg = raw_input() | |
except: | |
msg = input() | |
log('Received message "%s" from the Monitor' % msg) | |
running = False | |
th.join() |