Commit 38850868 authored by Philippe Pepiot's avatar Philippe Pepiot
Browse files

[entities] force convention for subtask created in a task

Convention is to return a dict with a key "celerytask_subtasks".
So we can remove a "except Exception" that could hide errors or future bugs.
parent 495f5c557506
......@@ -259,12 +259,12 @@ class CeleryTaskAdapter(ICeleryTask):
yield r
if isinstance(result, AsyncResult):
try:
rresult = from_serializable(result.result)
except Exception:
pass
else:
for r in tree(rresult, seen):
rresult = result.result
if (isinstance(rresult, dict)
and "celerytask_subtasks" in rresult):
subtasks = from_serializable(
rresult["celerytask_subtasks"])
for r in tree(subtasks, seen):
yield r
if result.task_id not in seen:
......
......@@ -62,5 +62,7 @@ def tsum(args):
@app.task(bind=True, name="spawn")
def spawn(self):
return chord((success.s(i) for i in range(10)), tsum.s() | add.s(-45))().serializable()
return {
"celerytask_subtasks": chord((success.s(i) for i in range(10)),
tsum.s() | add.s(-45))().serializable(),
}
......@@ -180,7 +180,8 @@ class CeleryTaskTC(BaseCeleryTaskTC):
self.assertEqual(cwtask.task_name, u'spawn')
run_all_tasks(cnx)
asresult = self.wait_async_task(cnx, cwtask.task_id)
result = celery.result.from_serializable(asresult.result)
result = celery.result.from_serializable(
asresult.result["celerytask_subtasks"])
self.assertEqual(0, result.get())
cwtask = cnx.entity_from_eid(cwtask.eid)
self.assertEqual(cwtask.cw_adapt_to('IWorkflowable').state, "done")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment