summaryrefslogtreecommitdiff
path: root/tasks.py
blob: e65a256179f59e7d139da3311635eb75d0e02b56 (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 celery.schedules import crontab

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

CELERYBEAT_SCHEDULE = {
    'every-ten-secs': {
        'task': 'tasks.print_fib',
        'schedule': crontab(minute='*/1'),
        '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))