Python sched Module
Example
Schedule a function to run after a delay:
import sched
import time
scheduler = sched.scheduler(time.time, time.sleep)
def greet():
print('Hello from Tobias!')
scheduler.enter(2, 1, greet)
scheduler.run()
Try it Yourself »
Definition and Usage
The sched module implements a general-purpose event scheduler for running functions at specific times.
Use it to schedule tasks to execute after delays or at specific times in a single-threaded environment.
Members
Member | Description |
---|---|
scheduler | Class that implements a general-purpose event scheduler. |
scheduler.cancel() | Cancel a scheduled event. |
scheduler.empty() | Return True if the event queue is empty. |
scheduler.enter() | Schedule an event with a delay relative to now. |
scheduler.enterabs() | Schedule an event at an absolute time. |
scheduler.run() | Run scheduled events until the queue is empty. |