Created
October 4, 2013 16:36
-
-
Save donalmacc/6828827 to your computer and use it in GitHub Desktop.
Input threaded.
This file contains hidden or 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 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