Skip to content

Instantly share code, notes, and snippets.

/t.py

Created September 15, 2011 15:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1219513 to your computer and use it in GitHub Desktop.
Save anonymous/1219513 to your computer and use it in GitHub Desktop.
import threading
import time
def bug(num):
while 1:
print "bug!^C may not work!thread-%d"%num
time.sleep(1)
threads=[]
for i in range(4):
th = threading.Thread(target=lambda : bug(i))
th.daemon = True
threads.append(th)
try:
for th in threads:
th.start()
while True: time.sleep(100)
except (KeyboardInterrupt):
print "Quitting"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment