Skip to content

Commit

Permalink
Flask-Celery no longer needed for Celery 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ask committed Jul 7, 2012
1 parent 495b216 commit 778e8d5
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 24 deletions.
78 changes: 55 additions & 23 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,39 +1,71 @@
==============================
Flask <-> Celery Integration
==============================
:Version: 2.4.1
:Version: 2.4.3

Requires `Celery`_ 2.3.0 or later, and Flask 0.8 or later.
**FROM CELERY 3.0 THIS LIBRARY IS NO LONGER NECESSARY, INSTEAD YOU SHOULD
USE THE STANDARD CELERY API**

.. _Celery: http://celeryproject.org

Installation Celery
===================
Using Flask with Celery
=======================

You can install Celery either via the Python Package Index (PyPI) or from source.
From Celery 3.0 the Flask-Celery integration package is no longer
recommended and you should use the standard Celery API instead.

To install using pip:
Please read the Celery getting started tutorial::

$ pip install Celery
http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html

To install using easy_install:

$ easy_install Celery
You can easily add Celery to your flask application like this::

To install from source:
::
$ tar xvfz celery-0.0.0.tar.gz
$ cd celery-0.0.0
$ python setup.py build
# python setup.py install (root user)
``myapp.py``::

Example
=======
from celery import Celery

You probably want to see some code by now, so you can see example/ for example usage (task
adding two numbers):
::
python manage.py celeryd
python myapp.py
celery = Celery('myapp', broker='amqp://guest@localhost//')

Check http://127.0.0.1:5000/
@celery.task
def add(x, y):
return x + y


To start the worker you can then launch the ``celery worker`` command
by pointing to your ``celery`` app instance::

$ celery -A myapp worker -l info

(if the app argument (``-A|--app)`` is a module/package instead of an
attribute
it will automatically expand into ``myapp.celery``)


See the commands help screen for more information::

$ celery help


If you want use the flask configuration as a source for the celery
configuration you can do that like this::

celery = Celery('myapp')
celery.config_from_object(flask_app.config)


If you need access to the request inside your task
then you can use the test context::

from flask import Flask
from celery import Celery

app = Flask('myapp')
celery = Celery('myapp')

celery.config_from_object(app.config)

@celery.task
def hello():
with app.test_request_context() as request:
print('Hello {0!r}.format(request))
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name='Flask-Celery',
version='2.4.2',
version='2.4.3',
url='http://github.com/ask/flask-celery/',
license='BSD',
author='Ask Solem',
Expand Down

0 comments on commit 778e8d5

Please sign in to comment.