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

Drop get_task_id()

Only Task objects pass through get_task_id() and never AsyncResult, thus get_task_id()
is now useless and is equivalent to task.freeze().id
I think an old version of attach_task() was recursively called with either Task
or AsyncResult thus the handling of both cases, but I cannot find the relevant
changeset (maybe this code was never used ? ...)
I'm pretty confident on this because all known use-cases are covered by tests.
parent c19d0234c332
......@@ -224,28 +224,13 @@ class ICeleryTask(EntityAdapter):
return self.state in FINAL_STATES
def get_task_id(task):
if hasattr(task, 'freeze'):
# false for ASyncResult
result = task.freeze()
result = task
if hasattr(result, 'task_id'):
return result.task_id
elif hasattr(result, 'id'):
# Group
return get_task_id(task.tasks[-1])
class CeleryTaskAdapter(ICeleryTask):
"""Base adapter that store task call args in the transaction"""
__select__ = ICeleryTask.__select__ & is_instance('CeleryTask')
def attach_task(self, task, seen, parent=None):
task_id = six.text_type(get_task_id(task))
task_id = six.text_type(task.freeze().id)
if parent is None:
parent = self.entity
if self.entity.task_id is None:
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