Created
September 13, 2013 07:35
-
-
Save chhantyal/6547720 to your computer and use it in GitHub Desktop.
Periodic tasks with celery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from celery.task.schedules import crontab | |
from celery.decorators import periodic_task | |
from .models import send_all | |
# Every ten minutes | |
@periodic_task(run_every=crontab(hour="*", minute="*/10", day_of_week="*")) | |
def send_newsletter(): | |
print("Sending Newsletters") | |
send_all() | |
# Every minute | |
@periodic_task(run_every=crontab(hour="*", minute="*", day_of_week="*")) | |
def every_minute(): | |
print("Every minute, I am called :(") | |
# Every minute | |
@periodic_task(run_every=crontab(minute="*/1")) | |
def hello_world(): | |
print("Hello world") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
celery.decorators will be removed in Celery 5.0