Scheduler
Methods
- Scheduler.__init__(timer: BaseTimer)[source]
Create a Scheduler object to handle events.
- Parameters:
timer (BaseTimer) – timer to use, subclass of BaseTimer.
- Raises:
ValueError – timer is not a valid argument.
- Scheduler.run_once(action, delay: float, *, priority: int = 1, arguments=(), kwargs={}) int [source]
Schedule a function for execution after a delay.
- Parameters:
action (callable) – function to be called.
delay (float) – delay in seconds.
priority (int, optional) – priority for this event, lower is more important. Defaults to 1.
arguments (tuple, optional) – arguments for the action. Defaults to ().
kwargs (dict, optional) – keyword arguments for the action. Defaults to dict().
- Returns:
event id that can be canceled.
- Return type:
int
- Scheduler.run_at(action, time: float, *, priority: int = 1, arguments=(), kwargs={}) int [source]
Schedule a function to be executed at a certain time.
- Parameters:
action (callable) – function to be called.
time (float) – epoch time at which the function should be called.
priority (int, optional) – priority for this event, lower is more important. Defaults to 1.
arguments (tuple, optional) – arguments for the action. Defaults to ().
kwargs (dict, optional) – keyword arguments for the action. Defaults to dict().
- Returns:
event id that can be canceled.
- Return type:
int
- Scheduler.run_every(action, delay: float, *, priority: int = 1, initial_delay: float = 0.0, arguments=(), kwargs={}) int [source]
Schedule a recurring function to be called every delay seconds after a initial delay.
- Parameters:
action (callable) – function to be called.
delay (float) – delay in seconds.
priority (int, optional) – priority for this event, lower is more important. Defaults to 1.
initial_delay (float, optional) – initial delay in seconds before executing for the first time.
arguments (Defaults to 0.) – arguments for the action. Defaults to ().
kwargs (dict, optional) – keyword arguments for the action. Defaults to dict().
- Returns:
event id that can be canceled.
- Return type:
int