Huey - a nice celery alternative

I am going to show a simple example of huey usage in django project.
The problem that huey should solve in this example - handle some hard tasks that should be done when user navigate to particular url.
The 'hard task' in example would be time.sleep(10) :).
To make sure that task was successfully done, we will calculate datetime.now() + 1 day and save result to file.

Installation and configuration

Huey is available on PyPI:

pip install huey

Also we'll need redis:

pip install redis

requirements.txt:

Django==1.5.1
huey==0.4.1
redis==2.7.6

myproject/settings.py:

HUEY={'backend':'huey.backends.redis_backend',# required.'name':'hueytest','connection':{'host':'localhost','port':6379},'always_eager':False,# Defaults to False when running via manage.py run_huey# Options to pass into the consumer when running ``manage.py run_huey``'consumer_options':{'workers':4},}

Running huey consumers on production

For code clarity, this is not provided as a part of 'huey'. Adding this would require a dependency outside the standard lib, which I'm not > really interested in adding. If you want, though, you should be able to very easily use:http://pypi.python.org/pypi/python-daemon/
I run all my web apps and consumers using supervisord.