Skip to content

Instantly share code, notes, and snippets.

@donalmacc
Created October 4, 2013 16:36
Show Gist options
  • Save donalmacc/6828827 to your computer and use it in GitHub Desktop.
Save donalmacc/6828827 to your computer and use it in GitHub Desktop.
Input threaded.
import time
from threading import *
key = "lol"
def getInput():
global key
lock = Lock()
while True:
with lock:
key = raw_input()
if key=="STOP":
break
p1 = Thread(target=getInput)
p1.start()
while True:
time.sleep(1)
print(key)
if key == "STOP":
break
p1.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment