Package turbogears :: Module scheduler

Module scheduler

source code

Module that provides a cron-like task scheduler.

Functions
 
add_cron_like_task(action, cron_str, args=None, kw=None, processmethod='threaded', taskname=None)
Add a task to the scheduler based on a cron-like syntax.
 
add_interval_task(action, interval, args=None, kw=None, initialdelay=0, processmethod='threaded', taskname=None)
Add an interval task to the scheduler.
 
add_monthday_task(action, monthdays, timeonday, args=None, kw=None, processmethod='threaded', taskname=None)
Add a monthly task to the scheduler.
 
add_monthly_task(action, monthdays, timeonday, args=None, kw=None, processmethod='threaded', taskname=None)
Add a monthly task to the scheduler.
 
add_single_task(action, args=None, kw=None, initialdelay=0, processmethod='threaded', taskname=None)
Add a single task to the scheduler.
 
add_weekday_task(action, weekdays, timeonday, args=None, kw=None, processmethod='threaded', taskname=None)
Add a weekday task to the scheduler.
 
add_weekly_task(action, weekdays, timeonday, args=None, kw=None, processmethod='threaded', taskname=None)
Add a weekday task to the scheduler.
 
cancel(task)
Cancel task by task name.
 
get_task(taskname)
Retrieve a task from the scheduler by task name.
 
get_tasks()
Retrieve all tasks from the scheduler.
 
rename_task(taskname, newname)
Rename a scheduled task.
 
start_scheduler()
Start the scheduler and register shutdown at exit.
 
stop_scheduler()
Stop the scheduler.
Function Details

add_cron_like_task(action, cron_str, args=None, kw=None, processmethod='threaded', taskname=None)

 

Add a task to the scheduler based on a cron-like syntax.

Parameters:
  • cron_str - The scheduling information, written in a cron-like syntax
  • action - The callable that will be called at the time you request
  • args - Tuple of positional parameters to pass to the action
  • kw - Keyword arguments to pass to the action
  • taskname - Tasks can have a name (stored in task.name), which can help if you're trying to keep track of many tasks.
  • processmethod - By default, each task will be run in a new thread. You can also pass in turbogears.scheduler.method.sequential or turbogears.scheduler.method.forked.

add_interval_task(action, interval, args=None, kw=None, initialdelay=0, processmethod='threaded', taskname=None)

 

Add an interval task to the scheduler.

Pass in initialdelay with a number of seconds to wait before running and an interval with the number of seconds between runs.

For example, an initialdelay of 600 and interval of 60 would mean "start running after 10 minutes and run every 1 minute after that".

Parameters:
  • interval - The interval in seconds between executing the action
  • initaldelay - the initial delay before starting execution
  • action - The callable that will be called at the time you request
  • args - Tuple of positional parameters to pass to the action
  • kw - Keyword arguments to pass to the action
  • taskname - Tasks can have a name (stored in task.name), which can help if you're trying to keep track of many tasks.
  • precessmethod - By default, each task will be run in a new thread. You can also pass in turbogears.scheduler.method.sequential or turbogears.scheduler.method.forked.

add_monthday_task(action, monthdays, timeonday, args=None, kw=None, processmethod='threaded', taskname=None)

 
Add a monthly task to the scheduler.

Runs on certain days of the month. Pass in a list or tuple of monthdays
from 1-31, import and also pass in timeonday which is an (hour, minute)
 tuple of the time of day to run the task.

@param monthdays: list ot tuple of monthdays to execute action
@param timeonday: tuple (hour, minute), to run on monthday

@param action: The callable that will be called at the time you request
@param args: Tuple of positional parameters to pass to the action
@param kw: Keyword arguments to pass to the action
@param taskname:  Tasks can have a name (stored in task.name), which
can help if you're trying to keep track of many tasks.
@param precessmethod: By default, each task will be run in a new
thread.
You can also pass in turbogears.scheduler.method.sequential or
turbogears.scheduler.method.forked.

add_monthly_task(action, monthdays, timeonday, args=None, kw=None, processmethod='threaded', taskname=None)

 
Add a monthly task to the scheduler.

Runs on certain days of the month. Pass in a list or tuple of monthdays
from 1-31, import and also pass in timeonday which is an (hour, minute)
 tuple of the time of day to run the task.

@param monthdays: list ot tuple of monthdays to execute action
@param timeonday: tuple (hour, minute), to run on monthday

@param action: The callable that will be called at the time you request
@param args: Tuple of positional parameters to pass to the action
@param kw: Keyword arguments to pass to the action
@param taskname:  Tasks can have a name (stored in task.name), which
can help if you're trying to keep track of many tasks.
@param precessmethod: By default, each task will be run in a new
thread.
You can also pass in turbogears.scheduler.method.sequential or
turbogears.scheduler.method.forked.

add_single_task(action, args=None, kw=None, initialdelay=0, processmethod='threaded', taskname=None)

 

Add a single task to the scheduler.

Runs a task once. Pass in ``initialdelay`` with a number of seconds to wait before running.

Parameters:
  • initaldelay - the initial delay before starting execution
  • action - The callable that will be called at the time you request
  • args - Tuple of positional parameters to pass to the action
  • kw - Keyword arguments to pass to the action
  • taskname - Tasks can have a name (stored in task.name), which can help if you're trying to keep track of many tasks.
  • precessmethod - By default, each task will be run in a new thread. You can also pass in turbogears.scheduler.method.sequential or turbogears.scheduler.method.forked.

add_weekday_task(action, weekdays, timeonday, args=None, kw=None, processmethod='threaded', taskname=None)

 

Add a weekday task to the scheduler.

Runs on certain days of the week. Pass in a list or tuple of weekdays from 1-7 (where 1 is Monday). Additionally, you need to pass in timeonday which is the time of day to run. timeonday should be a tuple with (hour, minute).

Parameters:
  • weekdays - list ot tuple of weekdays to execute action
  • timeonday - tuple (hour, minute), to run on weekday
  • action - The callable that will be called at the time you request
  • args - Tuple of positional parameters to pass to the action
  • kw - Keyword arguments to pass to the action
  • taskname - Tasks can have a name (stored in task.name), which can help if you're trying to keep track of many tasks.
  • precessmethod - By default, each task will be run in a new thread. You can also pass in turbogears.scheduler.method.sequential or turbogears.scheduler.method.forked.

add_weekly_task(action, weekdays, timeonday, args=None, kw=None, processmethod='threaded', taskname=None)

 

Add a weekday task to the scheduler.

Runs on certain days of the week. Pass in a list or tuple of weekdays from 1-7 (where 1 is Monday). Additionally, you need to pass in timeonday which is the time of day to run. timeonday should be a tuple with (hour, minute).

Parameters:
  • weekdays - list ot tuple of weekdays to execute action
  • timeonday - tuple (hour, minute), to run on weekday
  • action - The callable that will be called at the time you request
  • args - Tuple of positional parameters to pass to the action
  • kw - Keyword arguments to pass to the action
  • taskname - Tasks can have a name (stored in task.name), which can help if you're trying to keep track of many tasks.
  • precessmethod - By default, each task will be run in a new thread. You can also pass in turbogears.scheduler.method.sequential or turbogears.scheduler.method.forked.

cancel(task)

 

Cancel task by task name.

Parameters:
  • task - the task itself or the task.name of the task to cancel

get_task(taskname)

 

Retrieve a task from the scheduler by task name.

Parameters:
  • taskname - the name of the task to retrieve