diff --git a/README.rst b/README.rst index 3ce5805..22f6bdd 100644 --- a/README.rst +++ b/README.rst @@ -180,6 +180,12 @@ Admin page or directly from your code: repeats=24, next_run=arrow.utcnow().replace(hour=18, minute=0)) + # Use a cron expression + schedule('math.hypot', + 3, 4, + schedule_type=Schedule.CRON, + cron = '0 22 * * 1-5') + For more info check the `Schedules `__ documentation. diff --git a/docs/install.rst b/docs/install.rst index 12f21a6..e3b1363 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -88,6 +88,13 @@ Optional +- `Croniter `__ is an optional package that is used to parse cron expressions for the scheduler:: + + $ pip install croniter + + + + Add-ons ------- - `django-q-rollbar `__ is a Rollbar error reporter:: diff --git a/docs/schedules.rst b/docs/schedules.rst index 781a324..5e2a080 100644 --- a/docs/schedules.rst +++ b/docs/schedules.rst @@ -45,6 +45,13 @@ You can manage them through the :ref:`admin_page` or directly from your code wit repeats=24, next_run=arrow.utcnow().replace(hour=18, minute=0)) + # Use a cron expression + schedule('math.hypot', + 3, 4, + schedule_type=Schedule.CRON, + cron = '0 22 * * 1-5') + + Missed schedules ---------------- @@ -99,8 +106,9 @@ Reference :param args: arguments for the scheduled function. :param str name: An optional name for your schedule. :param str hook: optional result hook function. Dotted strings only. - :param str schedule_type: (O)nce, M(I)nutes, (H)ourly, (D)aily, (W)eekly, (M)onthly, (Q)uarterly, (Y)early or :attr:`Schedule.TYPE` + :param str schedule_type: (O)nce, M(I)nutes, (H)ourly, (D)aily, (W)eekly, (M)onthly, (Q)uarterly, (Y)early or (C)ron :attr:`Schedule.TYPE` :param int minutes: Number of minutes for the Minutes type. + :param str cron: Cron expression for the Cron type. :param int repeats: Number of times to repeat schedule. -1=Always, 0=Never, n =n. :param datetime next_run: Next or first scheduled execution datetime. :param dict q_options: options passed to async_task for this schedule @@ -140,7 +148,7 @@ Reference .. py:attribute:: TYPE - :attr:`ONCE`, :attr:`MINUTES`, :attr:`HOURLY`, :attr:`DAILY`, :attr:`WEEKLY`, :attr:`MONTHLY`, :attr:`QUARTERLY`, :attr:`YEARLY` + :attr:`ONCE`, :attr:`MINUTES`, :attr:`HOURLY`, :attr:`DAILY`, :attr:`WEEKLY`, :attr:`MONTHLY`, :attr:`QUARTERLY`, :attr:`YEARLY`, :attr:`CRON` .. py:attribute:: minutes @@ -148,6 +156,10 @@ Reference The number of minutes the :attr:`MINUTES` schedule should use. Is ignored for other schedule types. + .. py:attribute:: cron + + A cron string describing the schedule. You need the optional `croniter` package installed for this. + .. py:attribute:: repeats Number of times to repeat the schedule. -1=Always, 0=Never, n =n. @@ -208,3 +220,9 @@ Reference `'Y'` only runs once a year. The same caution as with months apply; If you set this to february 29th, it will run on february 28th in the following years. + + .. py:attribute:: CRON + + `'C'` uses the optional `croniter` package to determine a schedule based a cron expression. + +