-
apply:
官方注释:Execute this task locally, by blocking until the task returns(通过阻塞直到任务返回,在本地执行此任务)
即同步任务,不走celery worker。 -
apply_async:
def apply_async(self, args=None, kwargs=None, task_id=None, producer=None,
link=None, link_error=None, shadow=None, **options):
"""Apply tasks asynchronously by sending a message."""
if self.typing:
try:
check_arguments = self.__header__
except AttributeError: # pragma: no cover
pass
else:
check_arguments(*(args or ()), **(kwargs or {}))
app = self._get_app()
if app.conf.task_always_eager: # 如果celery conf设置了task_always_eager=True,则走apply()同步任务
with app.producer_or_acquire(producer) as eager_producer:
serializer = options.get(