Skip to content

Instantly share code, notes, and snippets.

@billroy
Created June 18, 2012 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billroy/2949377 to your computer and use it in GitHub Desktop.
Save billroy/2949377 to your computer and use it in GitHub Desktop.
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-n", "--number",
dest="count", type='int',
help="which potato am i")
parser.add_option("-x", "--exit",
dest="exit", type='int',
help="exit after this many logging cycles")
(options, args) = parser.parse_args()
potatocount = options.count or -1
print potatocount, "potatoes starting"
import sys
sys.stdout.flush()
import time
while options.exit:
time.sleep(5)
print potatocount, "potatoes here"
sys.stdout.flush()
options.exit = options.exit - 1
print potatocount, "potatoes finished"
sys.stdout.flush()
sys.exit(potatocount)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment