代码: 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
的作用是? 谢谢各位!
建议直接看源码,一般源码中有注释:
celery/app/task.py:
#: If :const:`True` the task is an abstract base class. abstract = True