ask/flask-celery — pull request #15 by imlucas (2012-01-20 17:15:52+00:00)
Title: Add app factory support via `init_app` with tests

After upgrading to Celery 2.4.6, wanted to revisit #6. Not sure about correctness, but working properly on our stack and added some tests. Feels nice.

from flask.ext.celery import Celery
from flask import Flask

celery = Celery()

@celery.task
def add(x, y):
return x + y

def create_app():
app = Flask(__name__)
return app

app = create_app()

celery.init_app(app)