작업 결과로 DependencyGraph
을 생성 할 수 있습니다.
In [4]: task_result = some_complex_task()
In [5]: task_result.parent.parent.graph
Out[5]: 285fa253-fcf8-42ef-8b95-0078897e83e6(1)
463afec2-5ed4-4036-b22d-ba067ec64f52(0)
872c3995-6fa0-46ca-98c2-5a19155afcf0(2)
285fa253-fcf8-42ef-8b95-0078897e83e6(1)
463afec2-5ed4-4036-b22d-ba067ec64f52(0)
이러한 그래프 파일을 도트로 변환 할 수 있습니다
In[22]: with open('graph.dot', 'w') as fh:
...: res.parent.parent.graph.to_dot(fh)
를 자세한 내용은 documentation을 확인하십시오.
예 작업에 대한 작업 이름을 인쇄 해 봅시다.
task_list.py : 작업 C에 대한
from celery import Celery, chain
celery_app = Celery('my_tasks', broker='amqp://', backend='amqp://')
@celery_app.task()
def add(x, y):
return x + y
@celery_app.task()
def sub(x, y):
return x - y
c = chain(add.s(3, 4), sub.s(2))
하위 이름 :
In [62]: r=c()
In [63]: r.parent.graph
Out[63]:
d11c0076-a4e4-4e84-b26b-9b689860baa5(0)
68ba78cf-7e6c-4735-9173-2349da541b28(1)
d11c0076-a4e4-4e84-b26b-9b689860baa5(0)
In [64]: r.graph
Out[64]: d11c0076-a4e4-4e84-b26b-9b689860baa5(0)
In [65]: while r:
....: print(r.task_name)
....: r = r.parent
....:
task_list.sub
task_list.add
내가 그들을 로그인 할 수 있도록 그래프 개체에서 모든 작업 ID를 얻을 수도 있습니다 ? –
@TomFerguson 가능합니다. 위의 예제를 새로 추가했습니다. – ChillarAnand
잘 작동합니다. 감사! –