summaryrefslogtreecommitdiff
path: root/tasks.py
diff options
context:
space:
mode:
authorYuval Adam <yuv.adm@gmail.com>2013-10-07 14:25:59 +0200
committerYuval Adam <yuv.adm@gmail.com>2013-10-07 14:25:59 +0200
commit5b03619a03747833e149aa6f304a5dfd18a756b6 (patch)
tree9ed2153790627deef32e1b392a631b9361229b6f /tasks.py
parent35898aeb87bbdc70c89b6efb9f72ba57ae1ffe8e (diff)
Add some descriptive comments
Diffstat (limited to 'tasks.py')
-rw-r--r--tasks.py7
1 files changed, 5 insertions, 2 deletions
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))