sched maintains an in-process event queue through configurable clock and delay functions. It suits simulations, tests, and small automations, but it is not a persistent job service.
Schedule an event
import sched
import time
scheduler = sched.scheduler(time.monotonic, time.sleep)
event = scheduler.enter(0.01, 10, print, argument=("executed",))
assert event in scheduler.queue
scheduler.run()
Use a monotonic clock
For relative delays, time.monotonic() does not move backward when the system clock changes. Events at the same time are ordered by priority, with a lower number running first.
Know the operational limits
A slow action delays later events even though ordering is preserved. Handle expected exceptions within tasks. If you need restarts, multiple workers, retries, or history, choose a persistent queue or scheduler.
Keep learning
Continue with persistent scheduling with APScheduler. The official Python documentation, accessed July 22, 2026, explains events, cancellation, and blocking or incremental execution.