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

[entities] use try/except to get or create CeleryTask

IMHO this looks better than "if rset".
Also log created entity eid.
parent 511c159acb12
...@@ -273,15 +273,15 @@ class CeleryTaskAdapter(ICeleryTask): ...@@ -273,15 +273,15 @@ class CeleryTaskAdapter(ICeleryTask):
for asr in tree(result): for asr in tree(result):
task_id = six.text_type( task_id = six.text_type(
rset = self._cw.find('CeleryTask', task_id=task_id) try:
if rset: cwtask = self._cw.find('CeleryTask', task_id=task_id).one()
cwtask = except NoResultError:
else:"create a CeleryTask for %s" % task_id)
cwtask = self._cw.create_entity( cwtask = self._cw.create_entity(
'CeleryTask', 'CeleryTask',
task_id=six.text_type(task_id)) task_id=six.text_type(task_id))"Create <CeleryTask %s (task_id %s)>",
cwtask.eid, task_id)
if not cwtask.parent_task and self.entity is not cwtask: if not cwtask.parent_task and self.entity is not cwtask:'Set %s parent_task to %s (%s)', cwtask.task_id,'Set %s parent_task to %s (%s)', cwtask.task_id,
self.entity, self.entity.task_id) self.entity, self.entity.task_id)
Supports Markdown
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