I am running a timer that gets input from user. However, if the user is unable to input anything, the timer should stop and the code should end but it keeps waiting for input even after time has ended. Can anyone help what I am doing wrong here? TIA
    import sys
    import threading as th
    from time import *
    
    
    def countdown():
        global my_timer
    my_timer = 4
    for x in range(my_timer):
        my_timer = my_timer - 1
        sleep(1)
    print("out of time \n")
countdown_thread = th.Thread(target=countdown)
countdown_thread.start()
while my_timer > 0:
    print('q1')
    sleep(1)
    answer = input('choose your answer\n')
    sleep(1)
    if my_timer == 0:
        sys.exit()
