From e2f7f1e5bfe2dded5f634c3af41966ba9a3ca176 Mon Sep 17 00:00:00 2001 From: Ilan Steemers Date: Thu, 25 Jun 2015 20:30:13 +0200 Subject: [PATCH] added schedule to README --- README.md | 9 ++++++++- README.rst | 18 +++++++++++++++--- django_q/__init__.py | 2 +- django_q/models.py | 10 +++++----- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 60d020e..60ead45 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,15 @@ You can monitor basic information about all the connected clusters by running ` ![qmonitor command](http://i.imgur.com/5cm7hdP.png) ###Admin integration -Django Q registers itself with the admin page to show failed and successful tasks. +Django Q registers itself with the admin page to show failed, successful and scheduled tasks. From there task results can be read or deleted. If necessary, failed tasks can be reintroduced to the queue. +Schedules be created and their results monitored. +![q admin](http://i.imgur.com/WTZkW9r.png) + +###Schedules +Scheduled tasks are a django model and can be created through the admin interface or by creating a Schedule instance directly. +Like the Async Task, a Schedule can take an optional hook keyword and is used as a template to create the actual task package at the scheduled time. +If a result task is available in the database, it can be accessed through the Schedule instance's `result()` method. ### Signed Tasks Tasks are first pickled to Json and then signed using Django's own signing module before being sent to a Redis list. This ensures that task packages on the Redis server can only be excuted and read by clusters and django servers who share the same secret key. diff --git a/README.rst b/README.rst index beaa041..6522d75 100644 --- a/README.rst +++ b/README.rst @@ -53,9 +53,20 @@ running ``./manage.py qmonitor`` Admin integration ~~~~~~~~~~~~~~~~~ -Django Q registers itself with the admin page to show failed and -successful tasks. From there task results can be read or deleted. If -necessary, failed tasks can be reintroduced to the queue. +Django Q registers itself with the admin page to show failed, successful +and scheduled tasks. From there task results can be read or deleted. If +necessary, failed tasks can be reintroduced to the queue. Schedules be +created and their results monitored. |q admin| + +Schedules +~~~~~~~~~ + +Scheduled tasks are a django model and can be created through the admin +interface or by creating a Schedule instance directly. Like the Async +Task, a Schedule can take an optional hook keyword and is used as a +template to create the actual task package at the scheduled time. If a +result task is available in the database, it can be accessed through the +Schedule instance's ``result()`` method. Signed Tasks ~~~~~~~~~~~~ @@ -119,3 +130,4 @@ I'll add to this README while I'm developing the various parts. .. |image0| image:: https://travis-ci.org/Koed00/django-q.svg?branch=master :target: https://travis-ci.org/Koed00/django-q +.. |q admin| image:: http://i.imgur.com/WTZkW9r.png diff --git a/django_q/__init__.py b/django_q/__init__.py index 6f27633..712f024 100644 --- a/django_q/__init__.py +++ b/django_q/__init__.py @@ -1,4 +1,4 @@ -from django_q.models import Task +from django_q.models import Task, Schedule from django_q.core import async default_app_config = 'django_q.apps.DjangoQConfig' diff --git a/django_q/models.py b/django_q/models.py index 7a7fe9c..d459b6a 100644 --- a/django_q/models.py +++ b/django_q/models.py @@ -79,10 +79,10 @@ class Failure(Task): class Schedule(models.Model): - func = models.CharField(max_length=256) - hook = models.CharField(max_length=256, null=True, blank=True) - args = models.CharField(max_length=256, null=True, blank=True) - kwargs = models.CharField(max_length=256, null=True, blank=True) + func = models.CharField(max_length=256, help_text='e.g. module.tasks.function') + hook = models.CharField(max_length=256, null=True, blank=True, help_text='e.g. module.tasks.result_function') + args = models.CharField(max_length=256, null=True, blank=True, help_text=_("e.g. 1, 2, 'John'")) + kwargs = models.CharField(max_length=256, null=True, blank=True, help_text=_("e.g. x=1, y=2, name='John'")) ONCE = 'O' HOURLY = 'H' DAILY = 'D' @@ -100,7 +100,7 @@ class Schedule(models.Model): (YEARLY, _('Yearly')), ) schedule_type = models.CharField(max_length=1, choices=TYPE, default=TYPE[0][0], verbose_name=_('Schedule Type')) - repeats = models.SmallIntegerField(default=-1, verbose_name=_('Repeats')) + repeats = models.SmallIntegerField(default=-1, verbose_name=_('Repeats'), help_text=_('n = n times, -1 = forever')) next_run = models.DateTimeField(verbose_name=_('Next Run'), default=timezone.now, null=True) task = models.CharField(max_length=100, editable=False, null=True)