代码: celery 构造函数,在celery中加载flask的app context:
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
请问,这里的abstract=True
的作用是? 谢谢各位!
Il est recommandé de regarder directement le code source. Généralement, il y a des commentaires dans le code source :
celery/app/task.py :