I would like to run a definition in the background, and pass an argument into it (how long it should run for), but the following code isn't working:
thread = threading.Thread(target= run_timer, args=timer_time_value) # Where timer_time_value is taken from user input, and converted into an integer.
thread.daemon = True
thread.start()
def run_timer(time_to_sleep_For):
time_to_sleep_For = int(time_to_sleep_For)
time.sleep(time_to_sleep_For)
Speak("Timer done!")
If I use process, I replace the first chunk of code with:
p = Process(target= run_timer, args=timer_time_value)
p.start()
p.join()
However, both return:
TypeError: 'int' object is not iterable
My question is, which module should I use, and what is the correct way to set it up?