summaryrefslogtreecommitdiff
path: root/tasks.py
blob: 5ece5fc782ad68a666f45cf82088667d10f047f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import logging

from celery import Celery
from datetime import timedelta

celery = Celery('tasks', broker='redis://localhost')

CELERYBEAT_SCHEDULE = {
    'every-ten-secs': {
        'task': 'tasks.print_fib',
        'schedule': timedelta(seconds=10),
        'args': (30),
    },
}


def fib(n):
    if n > 1:
        return fib(n - 1) + fib(n - 2)
    else:
        return 1


@celery.task
def print_fib(n):
    logging.info(fib(n))