I have a function f()that I want to run from time to time, let's say each 10 seconds. My goal is to run it indefinitely, only being killed by a interrupt. I looked into the sched module, but couldn't find how to run the function repeatedly ad infinitum. Maybe a while True loop?
timemodule withtime.sleep(10)in awhile Trueloop, unless your requirement is more complicated than you have explained in the question. Note that this will give a 10 second pause after each function call, but will not take into account how long the function itself takes to execute.from time import sleep sleep(0.1) # Time in seconds