def user_input():
    global response
response = input('Do you wish to reconnect? ')
user = threading.Thread(target=user_input)
user.daemon = True
user.start()
user.join(2)
if response is None:
    print() 
print('Exiting')
Python cancel raw_input/input via writing to stdin?