Question

I'm trying to get a basic example of this up and running:

http://flask.pocoo.org/docs/patterns/celery/

So the article suggest placing this in a tasks module:

from celery import Celery

def make_celery(app):
    celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL'])
    celery.conf.update(app.config)
    TaskBase = celery.Task
    class ContextTask(TaskBase):
        abstract = True
        def __call__(self, *args, **kwargs):
            with app.app_context():
                return TaskBase.__call__(self, *args, **kwargs)
    celery.Task = ContextTask
    return celery

and this flask app.

from flask import Flask

flask_app = Flask(__name__)
flask_app.config.update(
    CELERY_BROKER_URL='redis://localhost:6379',
    CELERY_RESULT_BACKEND='redis://localhost:6379'
)
celery = make_celery(flask_app)


@celery.task()
def add_together(a, b):
    return a + b    

But so far it just doesn't make sense as to what goes where.

Could somebody please provide a simple Flask-Celery 3 working example.

Regards,

Carl

No correct solution

OTHER TIPS

Github Repo for Flask-Celery

I quote the author

FROM CELERY 3.0 THIS LIBRARY IS NO LONGER NECESSARY, INSTEAD YOU SHOULD USE THE STANDARD CELERY API

For this reason is not necessary the use of Flask-Celery, Celery is independent of Flask. Please use the Flask good patterns.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top