This is a very basic and useless example of Celery extending Django with asynchronous tasks, it consist of a simple task that counts to the provided number and sleeps one second in every iteration, using AJAX to check the status of this task from the client side.
This example makes use of a virtual machine that runs the Django server and the Redis backend for Celery.
A development environment that runs Git, Oracle's VirtualBox, Vagrant, Python and Fabric.
- Clone the reposiroty.
$ git clone git@github.com:gGonz/django_celery_example.git- Create the virtual machine.
$ cd django_celery_example
$ vagrant up- Build the environment inside the virtual machine.
$ fab vagrant bootstrap- Run Celery on the virtual machine.
$ vagrant ssh # ssh into the virtual machine
$ cd django_site # cd into the site directory
$ nohup python manage.py celery worker & # run Celery in the background
$ exit # close the ssh session- Run the virtual server.
$ fab vagrant runserver- Open your browser and go to your virtual server on
http://127.0.0.1:8000
http://docs.celeryproject.org/en/latest/index.html