각 작업 상태를 쿼리하여 작업 체인의 진행을 얻으려고합니다. 하지만 ID로 체인을 검색 할 때, 나는 다르게 동작하는 객체를 얻습니다. 레디 스에서 파이썬 2.7.3와 셀러리 3.0.19을 사용 체인 ID로 비동기 파이썬 셀러리 체인에서 진행하십시오.
ipython에서 quering
tasks.pyfrom celery import Celery
celery = Celery('tasks')
celery.config_from_object('celeryconfig')
def unpack_chain(nodes):
while nodes.parent:
yield nodes.parent
nodes = nodes.parent
yield nodes
@celery.task
def add(num, num2):
return num + num2
에서
...
In [43]: from celery import chain
In [44]: from tasks import celery, add, unpack_chain
In [45]: c = chain(add.s(3,3), add.s(10).set(countdown=100))
In [46]: m = c.apply_async()
In [47]: a = celery.AsyncResult(m.id)
In [48]: a == m
Out[48]: True
In [49]: a.id == m.id
Out[49]: True
In [50]: [t.status for t in list(unpack_chain(a))]
Out[50]: ['PENDING']
In [51]: [t.status for t in list(unpack_chain(m))]
Out[51]: ['PENDING', 'SUCCESS']
. 만약 50 & 51에서 볼 수 있듯이
는 celery.AsyncResult
의해 리턴 된 값은 원래 체인과 다르다.
어떻게 체인 ID로 원래 체인 작업 목록을 얻을 수 있습니까?
celery.AsyncResult는 result.parent 포인터를 잃어버린 것처럼 보입니다. – Hernantz
나는 이걸 가지고 어디든 가지고 있는지 알고 싶어합니다. 비슷한 일을하려고합니다. – MikeTheReader
irc에 묻기도하고 github에서 티켓을 열어도 도움이 전혀 없습니다. 기본적으로 여전히 손상되었습니다. 운 좋게도, 나의 요구 사항은 체인으로 그룹화 된 일부 작업에 대한 체인의 글로벌 상태를 묻는 것을 허용했습니다. 다른 작업은 사소한 지연에 의해 체인에 "추가"됩니다 : mytask.s() .set (countdown = 980) .apply_async()':(더 어딘가에 있다면 알려주십시오.) – Hernantz