4

My goal is to retrieve all the task_ids from a django celery chord call so that I can revoke the tasks later if needed. However, I cannot figure out the correct method to retrieve the task ids. I execute the chord as:

c = chord((loadTask.s(i) for i in range(0, num_lines, CHUNK_SIZE)), finalizeTask.si())
task_result = c.delay()
# get task_ids

I examined the task_result's children variable, but it is None.

I can manual create the chord semantics by using a group and another task as follows, and retrieve the associated task_ids, but I do not like breaking up the call. When this code is run within a task as subtasks, it can cause the main task to hang when the group is revoked before the finalize task begins.

g = group((loadTask.s(i) for i in range(0, num_lines, CHUNK_SIZE))) 
task_result = g.delay()
storeTaskIds(task_result.children)
task_result.get()

task_result2 = self.finalizeTask.delay()
storeTaskIds([task_result2.task_id])

Any thoughts would be appreciated!

user2701815
  • 161
  • 1
  • 9

1 Answers1

1

I'm trying to do something similar, I was hoping I could just revoke the chord with one call and everything within it would be recursively revoked for me.

You could make a chord out of the group and your finalizeTask to keep from breaking up the calls.

I realize this is coming two months after you asked, but maybe it'll help someone and maybe I should just get the task ids of everything in my group.

abrugh
  • 195
  • 1
  • 1
  • 10