I've looked into PeriodicTask
, but the examples only cover making it recur. I'm looking for something more like cron
's ability to say "execute this task every Monday at 1 a.m."
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Django __str__ returned non-string (type NoneType)
- Evil ctypes hack in python
Use
And at the end of your task, reschedule it to the next time it should run.
While @asksol's answer still holds, the api has been updated. For celery 4.1.0, I have to import
crontab
andperiodic_task
as follows:The recently released version 1.0.3 supports this now, thanks to Patrick Altman!
Example:
See the changelog for more information:
http://celeryproject.org/docs/changelog.html
How you can read in this tutorial, you can make a PeriodicTask, i think if you have execute a task at 1 .am. Monday's morning is because you wan to run a long cpu/mem operation, rememeber celery use ampq for enqueue tasks.
I have just submitted a patch to add a ScheduledTask to accomplish a small bit of time based scheduling versus period based:
https://github.com/celery/celery/commit/e8835f1052bb45a73f9404005c666f2d2b9a9228