Question

I am starting a set of celery tasks by using celery group as described in the official documentation

I am also storing the group (taskset) id into a db, in order to poll celery for the taskset state.

job = group([
        single_test.s(1, 1),
        single_test.s(1, 2),
        single_test.s(1, 3),
    ])

result = job.apply_async()

test_set = MyTestSet()
test_set.taskset_id = result.id

# store test_set into DB

Is there a way to obtain a GroupResult object (i.e. my result) starting from the taskset id? Something like what is done in this question, but working with celery groups.

I already tried doing:

r = GroupResult(taskset_id)

but it does not work, as r.results() is always empty.

Should I use GroupResult.save() and GroupResult.restore() methods?

Was it helpful?

Solution

Yes you have to save the result and then restore it.

job = group([
    single_test.s(1, 1),
    single_test.s(1, 2),
    single_test.s(1, 3),
])
result = job.apply_async()
result.save()

from celery.result import GroupResult
saved_result = GroupResult.restore(result.id)

I had the same issue and after seeing your hint about save/restore eventually figured it out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top