cari

Rumah  >  Soal Jawab  >  teks badan

python - make_celery 构造函数中的 abstract=True 的作用?

代码: 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的作用是? 谢谢各位!

阿神阿神2802 hari yang lalu851

membalas semua(1)saya akan balas

  • 黄舟

    黄舟2017-04-18 09:27:34

    Adalah disyorkan untuk melihat langsung kod sumber Secara amnya, terdapat ulasan dalam kod sumber:
    celery/app/task.py:

    #: If :const:`True` the task is an abstract base class.
    abstract = True

    balas
    0
  • Batalbalas