0

I am using kivy and I'm trying to find a way to "reset" my thread after its finished, though I know that resetting threads is impossible. So, how would I have a thread run after its run once before if I tell it to? I have a screen set up with a button that when pressed runs a thread for 5 seconds then after 5 seconds returns me to the original screen, But if I press the button after its been pressed before I get an error saying threads can only be used once. Here is the code for the thread. I'm calling it when the screen first appears using on_pre_enter()

def countdown1():
    seconds = 5
    for i in range(seconds):
        timeleft = seconds-i
        print(str(timeleft) + " seconds remain")
        time.sleep(1)
    print("out of time")
    sm.current = "Evaluation"
    seconds = 5

countdown1_thread = threading.Thread(target = countdown1)

1 Answers1

0

Try replacing

countdown1_thread.start()

with:

threading.Thread(target = countdown1).start()
John Anderson
  • 35,991
  • 4
  • 13
  • 36