How can I get the task_id value for a task from within the task? Here's my code:
from celery.decorators import task
from django.core.cache import cache
@task
def do_job(path):
"Performs an operation on a file"
# ... Code to perform the operation ...
cache.set(current_task_id, operation_results)
The idea is that when I create a new instance of the task, I retrieve the task_id
from the task object. I then use the task id to determine whether the task has completed. I don't want to keep track of the task by the path
value because the file is "cleaned up" after the task completes, and may or may not exist.
In the above example, how would I get the value of current_task_id
?