Scheduler service

The scheduler service can be used to do time based - time-phased, periodic, single shot - tasks which may be scheduled by a user or by indirectly by a script or the web frontend.

>>> proxy.schedulerGetJobs()
{u'b4b54880-dac9-11e0-b58e-5452005f1250': {u'next_run_time':
u'20110909115527', u'name': u'SchedulerService.migrate',
u'misfire_grace_time': 1, u'job_type': None, u'max_instances': 1,
u'max_runs': None, u'coalesce': True, u'tag': u'_internal', u'owner': None,
u'description': None}}
>>> proxy.schedulerGetJobs({'tag':'service'})
{}
>>> proxy.schedulerAddDateJob("notifyUser", ["cajus", "test", "test"], None, "20110909131212")
u'596b8f2e-dad4-11e0-bcf1-5452005f1250'

class clacks.agent.scheduler.SchedulerService

The scheduler service provider.

schedulerAddDateJob(user, queue, func, args, kwargs, date, **options)

Note

This method will be exported by the CommandRegistry.

Add a new job triggered at a specified date.

Parameter Description
func Function pointer
args Function arguments
kwargs Function keyword arguments
date Execution date of the function
options Set of job options

A job can have these options:

Option Description
name Job name
description Description of the job
tag Free choosable text tag to make it easier to find jobs
progress Automatically maintained
misfire_grace_time seconds after the designated run time that the job is still allowed to be run
coalesce Roll several pending executions of jobs into one
max_runs Maximum number of times this job is allowed to be triggered
max_instances Maximum number of concurrently running instances allowed for this job
callback Function to be called after the job has been done

Return: Job ID

schedulerCronDateJob(user, queue, func, args, kwargs, year=None, month=None, day=None, week=None, day_of_week=None, hour=None, minute=None, second=None, start_date=None, **options)

Note

This method will be exported by the CommandRegistry.

Add a new job triggered in a cron style manner.

Parameter Description
func Function pointer
args Function arguments
kwargs Function keyword arguments
year Year to run on
month Month to run on
day Day of month to run on
week Week of the year to run on
day_of_week Weekday to run on (0 = Monday)
hour Hour to run on
second Second to run on
options Set of job options

For an option description, see clacks.agent.scheduler.SchedulerService.schedulerDateJob().

Return: Job ID

schedulerGetJobs(fltr=None)

Note

This method will be exported by the CommandRegistry.

List available jobs with filtering for job properties.

Example:

>>> proxy.schedulerGetJobs()
{u'b4b54880-dac9-11e0-b58e-5452005f1250': {
u'next_run_time': u'20110909115527',
u'name': u'SchedulerService.migrate',
u'misfire_grace_time': 1,
u'job_type': None,
u'max_instances': 1,
u'max_runs': None,
u'coalesce': True,
u'tag': u'\_internal',
u'owner': None,
u'description': None}}
>>> proxy.schedulerGetJobs({'tag':'service'})
{}
Parameter Description
fltr Dictionary containing job options to filter for

Return: Dictionary of jobs, indexed by job id

schedulerIntervalJob(user, queue, func, args, kwargs, weeks=0, days=0, hours=0, minutes=0, seconds=0, start_date=None, **options)

Note

This method will be exported by the CommandRegistry.

Add a new job triggered in a specified interval.

Parameter Description
func Function pointer
args Function arguments
kwargs Function keyword arguments
weeks Number of weeks to wait
days Number of days to wait
hours Number of hours to wait
minutes Number of minutes to wait
seconds Number of seconds to wait
start_date When to first execute the job
options Set of job options

For an option description, see clacks.agent.scheduler.SchedulerService.schedulerDateJob().

Return: Job ID

schedulerRemoveJob(user, job_id)

Note

This method will be exported by the CommandRegistry.

Remove a job by it’s job ID.

Parameter Description
job_id The job ID

Return: True on success

serve()

Start the scheduler service.

stop()

Stop scheduler service.