earwax.task module

Provides the Task class.

class earwax.task.Task(interval: Callable[[], float], func: Callable[[float], None])

Bases: object

A repeating task.

This class can be used to perform a task at irregular intervals.

By using a function as the interval, you can make tasks more random.

Parameters:
  • interval – The function to determine the interval between task runs.
  • func – The function to run as the task.
  • running – Whether or not a task is running.
start(immediately: bool = False) → None

Start this task.

Schedules func to run after whatever interval is returned by interval.

Every time it runs, it will be rescheduled, until stop() is called.

Parameters:immediately – If True, then self.func will run as soon as it has been scheduled.
stop() → None

Stop this task from running.