Celery:如何检查当前功能是否正在作为任务运行?

时间:2018-07-12 22:57:02

标签: python celery

当前,我只是将参数传递给函数,以表明我正在将函数作为celery任务运行:

@celery_app.task
def my_task(is_task=False):
    if is_task:
       # don't wait for group of subtasks to finish
       return
    else:
       # wait for subtasks results
       return results

我正在寻找这样的东西:

@celery_app.task
def my_task():
    if my_task.called_as_task:
       # don't wait for group of subtasks to finish
       return
    else:
       # wait for subtasks results
       return results

0 个答案:

没有答案