Browse Source

fixed documentation that still referenced original form of crontab PeriodicTask scheduling

Patrick Altman 15 năm trước cách đây
mục cha
commit
970a01c246
1 tập tin đã thay đổi với 7 bổ sung7 xóa
  1. 7 7
      docs/getting-started/periodic-tasks.rst

+ 7 - 7
docs/getting-started/periodic-tasks.rst

@@ -20,20 +20,20 @@ Here's an example of a periodic task:
     >>> tasks.register(MyPeriodicTask)
 
 If you want a little more control over when the task is executed, for example,
-a particular time of day or day of the week, you can subclass a ``ScheduledTask``:
+a particular time of day or day of the week, you can use ``crontab`` to set
+the ``run_every`` property:
 
 .. code-block:: python
 
-    from celery.task import ScheduledTask
+    from celery.task import PeriodicTask
+    from celery.task.schedules import crontab
 
-    class EveryMondayMorningTask(ScheduledTask):
-        hour = 7
-        minute = 30
-        day_of_week = 1
+    class EveryMondayMorningTask(PeriodicTask):
+        run_every = crontab(hour=7, minute=30, day_of_week=1)
 
         def run(self, **kwargs):
             logger = self.get_logger(**kwargs)
-            logger.info("This will execute every Monday at 7:30AM.")
+            logger.info("Execute every Monday at 7:30AM.")
 
 If you want to use periodic tasks you need to start the ``celerybeat``
 service. You have to make sure only one instance of this server is running at