Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #867 (closed enhancement: fixed)

Opened 13 years ago

Last modified 10 years ago

Background tasks, like a one-time forked schedule

Reported by: rob@… Owned by: jorge.vargas
Priority: normal Milestone: 1.1.x bugfix
Component: TurboGears Version: 0.9a6
Severity: normal Keywords:
Cc:

Description

It would be good to have the ability to schedule a one-time background task. This is for time consuming operations that you want to perform only once. You could use this for all sorts of things. In my app I want to be able to get feed information from a user-submitted RSS feed.

This could be implemented easily by adding another scheduler option that doesn't have a repeat.

Change History

comment:1 Changed 13 years ago by kevin

Karl just posted this to the mailing list:

....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

comment:2 Changed 13 years ago by jorge.vargas

  • Owner changed from anonymous to jorge.vargas
  • Milestone set to 1.0

I added this and some other goodies to a code I put into the trunk a while ago.

but since it's not documented it still doesn't exits http://trac.turbogears.org/turbogears/browser/trunk/turbogears/scheduler.py

I didn't put in the datetime I'll take this as a task for when I document the whole thing.

comment:3 Changed 12 years ago by alberto

  • Milestone changed from 1.0 to 1.1

comment:4 Changed 12 years ago by alberto

  • Milestone changed from 1.1 to __unclassified__

Batch moved into unclassified from 1.1 to properly track progress on the later

comment:5 Changed 10 years ago by jorge.vargas

  • Milestone changed from __unclassified__ to 1.1 maintenance

Do we still care about the scheduler?

comment:6 Changed 10 years ago by Chris Arndt

  • Status changed from new to closed
  • Resolution set to fixed

Actually, this is already implemented: #1710

BTW, can you please leave it to the release manager (i.e. Florent) to move tickets into the maintenance milestone? Thx.

comment:7 Changed 10 years ago by jorge.vargas

sorry about that should I be using 1.1 then?

Note: See TracTickets for help on using tickets.