This library provides a simple, dependency-free interface to run a single function in the background, repeatedly, at a specified interval. The function invocations are serial, and executed in a single thread.
It's really just a little extension for the built-in sched module.
pip install tinysched
from tinysched import scheduler from datetime import timedelta def foo(): print('foo!') cancel_fn = scheduler.repeat(foo, interval=timedelta(seconds=0.1), max_repeats=10) # manually cancel! cancel_fn()