def make_celery(app):
"""
:function: make_celery
:args:
- app: restccnu app
:rv: celery??
celery????, ?celery context???flask app context,
????flask??
"""
celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL'])
celery.conf.update(app.config)
TaskBase = celery.Task
class ContextTask(TaskBase):
abstract = True # abc
def __call__(self, *args, **kwargs):
with app.app_context():
return TaskBase.__call__(self, *args, **kwargs)
celery.Task = ContextTask
return celery
评论列表
文章目录