I'm looking at the internals of this I I believe sending in interval=0 will do a one-time task

Looking all the way into the sched.py module you will see the sheduler class enter and enterabs, so 0 will make both functions "equal"

then you will see in the run method it just get call

that will be calling

add_interval_task(action,0)

Can someone with a co test this?

On 5/12/06, Karl Guertin <[EMAIL PROTECTED]> wrote:

I found that the scheduler is missing one piece of functionality that
I'd like. I currently have a datetime object and I want to run a given
action at the time specified by my object. To that end I've added the
following functionality to scheduler:

....def add_datetime_task(self, action, taskname, date_time,
processmethod, args, kw):
........"""Add a new task to the schedule. This provides a way to
generate one-time
........   events where you know the time you want the event to occur"""
........now = time.time()
........date_time = time.mktime(date_time.timetuple())
........if date_time - now < 0:
............return None
........if processmethod==method.sequential:
............TaskClass=OneTimeTask
........elif processmethod==method.threaded:
............TaskClass = ThreadedOneTimeTask
........elif processmethod = method.forked:
............TaskClass = ForkedOneTimeTask
........if not args:
............args = []
........if not kw:
............kw = {}
........task = TaskClass(taskname, date_time, action, args, kw)
........self.schedule_task_abs(task,date_time)
........return task

class OneTimeTask(Task):
....def __init__(self, name, date_time, action, args=None, kw=None):
........Task.__init__(self, name, action, args, kw)

....def reschedule(self, scheduler):
........pass


Along with the mixins and convenience function. It seems to work, but
before I shoot myself in the foot, will I have a problem with an
excessive number of threads?

It doesn't look like I get a thread for every datetime_task added but
my knowledge of the threading module is weak and I don't see the
scheduling threads ever dying.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to