The recur module provides iterators for datetime objects. Recurrence patterns can be provided in natural language strings like "every 3 days" or "Sept 14" (currently, only a English Locale is provided). For example, this code:
d = recur.Recurrence(datetime.date(1999, 11, 28), "-5 each month")
Will make "d" an iterator, producing datetime.date objects starting with datetime.date(1999, 12, 26), and then proceeding to the fifth-from-last date of each succeeding month.
The Worker class
The recur module now includes a Worker class, which spawns new threads as needed to accomplish recurring tasks. Subclass it and override its "work" method. You can set its "paused" and "terminated" attributes to True/False as needed to manage a recurring task.
(N.B. -- Python 2.3.5 and 2.4.1 have some issues when spawning new threads in a subinterpreter, like those found in mod_python. If you find (as I did) that Worker threads are being created but not executed, check your Python version. See the Sourceforge ticket for more details.)
Q: How can I run a Worker task only once?
A1: In the "work" method (which you need to override), set self.terminated to True. You should probably do this before performing the work, in case the time to perform the work is actually longer than the recurrence cycle.
A2: Provide a Recurrence object (instead of a recurrence string) and set its endDate.