It's not a perfect solution, but you could try using multiprocessing:
import multiprocessing
import queue
def take_input(q):
stdin = open(0)
print("Enter your input: (y/n) >> ", end="", flush=True)
user_input = stdin.readline()
q.put(user_input)
def confirm_user_input():
value = ''
if __name__ == "__main__":
q = multiprocessing.Queue()
process = multiprocessing.Process(target=take_input, args=(q,))
process.start()
try:
value = q.get(timeout=10)
except queue.Empty:
print("no input...")
process.terminate()
process.join()
if value.strip() == 'y':
print("confirmed: do something in this case...")
else:
print("not confirmed: do something else in that case...")
confirm_user_input()
This doesn't use input(), but it waits for response for n seconds and if there's no input, continues with something else and it doesn't require Unix system. Keep in mind it needs to be in main. Otherwise you should call it from the main with something like this:
if __name__ == '__main__':
freeze_support()
confirm_user_input()
In that case remove if __name__ == "__main__":
from the function.
May be you could implement it in your code.