Scheduled Tasks

The ScheduledTask model offers a wrapped caller for a task that manages time commitments for the scheduling. If the task is not recurring and called manually, it will not run when it is scheduled (it will be considered run and not run again). The object is also comparable to datetime objects to determine if the next targetted runtime has been reached.

class lazbot.schedule.ScheduledTask(action=None, delta=None, when=None, recurring=None, name=None)[source]

Setup one time or recurring scheduled task

Will attempt to figure out the next time the action should be run and return a task to be added to the pool. If an absolute time is provided it will attempt to figure out the next time that time will occur, the time can be any of date, time, or datetime. If it is in the past, it will figure out the next logical time to run it.

If no absolute time is provided, the relative time from when the task is scheduled will be used.

If recurring is True. A relative value will be calculated if not provided and will be added to the current time for the next run after each time the task is run. So if it runs at midnight and then a delta of 1 hour, it will run every hour from midnight on.

Example: ::
task = ScheduledTask(action=lambda: print “o’clock”,
delta=timedelta(hours=1), when=time(0, 0, 0), recurring=True)

This example will print o'clock every hour after midnight.

Parameters:
  • action – function to be called when the task is run
  • delta – (optional) relative timedelta for the time scheduling
  • when – (optional) absolute time for when to run this task
  • recurring – boolean flag for whether this task should be run more than once

https://secure.travis-ci.org/jdost/lazbot.png?branch=master

Navigation