summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <yuval@y3xz.com>2015-03-12 18:58:07 +0200
committerYuval Adam <yuval@y3xz.com>2015-03-12 18:58:07 +0200
commit66e23866b713d126112da6afd664e4e87c894389 (patch)
tree138ec828baeb793b9b582516e9a6bf4e1566a2fa
parentb55988c0dfd4e8a61f351dff27d01841036a79bc (diff)
Update to modern Celery config using CELERYBEAT_SCHEDULE
-rw-r--r--tasks.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/tasks.py b/tasks.py
index fa6b143..81cbda6 100644
--- a/tasks.py
+++ b/tasks.py
@@ -1,7 +1,6 @@
import logging
-from celery import Celery
-from celery.task import periodic_task
+from celery import Celery, task
from datetime import timedelta
from os import environ
@@ -15,7 +14,13 @@ app = Celery('tasks')
app.conf.update(
BROKER_URL=REDIS_URL,
CELERY_TASK_SERIALIZER='json',
- CELERY_ACCEPT_CONTENT=['json', 'msgpack', 'yaml']
+ CELERY_ACCEPT_CONTENT=['json'],
+ CELERYBEAT_SCHEDULE = {
+ 'print-fibonacci': {
+ 'task': 'tasks.print_fib',
+ 'schedule': timedelta(seconds=10)
+ },
+ }
)
# Define the fibonacci function for use in our task
@@ -26,7 +31,7 @@ def fib(n):
return 1
# The periodic task itself, defined by the following decorator
-@periodic_task(run_every=timedelta(seconds=10))
+@task
def print_fib():
# Just log fibonacci(30), no more
logging.info(fib(30))