(How) can I activate a periodic timer interrupt in Python? For example there is a main loop and a timer interrupt, which should be triggered periodically:
def handler():
# do interrupt stuff
def main():
init_timer_interrupt(<period>, <handler>);
while True:
# do cyclic stuff
if __name__ == "__main__":
main();
I have tried the examples found at Executing periodic actions in Python, but they are all either blocking the execution of main(), or start spawning new threads.
Any solution will either block the main(), or spawn new threads if not a process.
The most commonly used solution is:
It can be used recursively, one simple application is:
this solution will not drift over the time