I am developing a Flask application and am using drawings. I plan on using celery task queues. I'm trying to understand the benefit or reason to use something like
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 then do
celery = make_celery(app)
and import it into my .py tasks compared to importing and instantiating celery in my tasks. Such as
from celery import Celery app = Celery('hello', broker='amqp:// guest@localhost //') @app.task def mytask():
source share