Last active
March 5, 2017 15:09
-
-
Save AJamesPhillips/bc138b0a6d353d033e392cb39bca3fd9 to your computer and use it in GitHub Desktop.
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 time | |
import threading | |
input_thread_values = [] | |
def input_thread(): | |
print('press s and enter to stop...') | |
global input_thread_values | |
input_thread_values.append(input()) | |
print('input_thread has got: {}'.format(input_thread_values)) | |
def do_stuff(): | |
t = threading.Thread(target=input_thread) | |
t.daemon = True # thread dies when main thread (only non-daemon thread) exits. | |
t.start() | |
global input_thread_values | |
while not input_thread_values: | |
print('sleeping') | |
time.sleep(1) | |
print('interrupted: {}'.format(input_thread_values)) | |
do_stuff() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment