From 5b03619a03747833e149aa6f304a5dfd18a756b6 Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Mon, 7 Oct 2013 14:25:59 +0200 Subject: Add some descriptive comments --- tasks.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tasks.py') diff --git a/tasks.py b/tasks.py index 9d6e78d..c08c357 100644 --- a/tasks.py +++ b/tasks.py @@ -5,18 +5,21 @@ from celery.task import periodic_task from datetime import timedelta from os import environ +# Fetch the Redis connection string from the env, or use localhost by default REDIS_URL = environ.get('REDISTOGO_URL', 'redis://localhost') +# Setup the celery instance under the 'tasks' namespace celery = Celery('tasks', broker=REDIS_URL) - +# Define the fibonacci function for use in our task def fib(n): if n > 1: return fib(n - 1) + fib(n - 2) else: return 1 - +# The periodic task itself, defined by the following decorator @periodic_task(run_every=timedelta(seconds=10)) def print_fib(): + # Just log fibonacci(30), no more logging.info(fib(30)) -- cgit v1.3.1