If a single event is to be handled, then the easiest way is to use the signal
framework which is a standard module of Python.
However, if we need a fully-fledged scheduler, then we have to resort to another module: sched
. Here is a pointer to the official documentation. Please be aware, though, that in multi-threaded environments sched
has limitations with respect to thread-safety.
Another option is the Advanced Python Scheduler, which is not part of the standard distribution.