Closed hsenot closed 1 year ago
@hsenot I'm not working on that project anymore and unfortunately can't verify one way or the other from my side!
@hsenot are you using track_started=True
? If not, then the Task Result is created at nearly the same time of done.
@shared_task(bind=True, name="default_task", track_started=True)
def default_task(self, files=None):
start = str(timezone.now())
sleep(10)
end = str(timezone.now())
return f"{start=}\n{end=}"
https://docs.celeryq.dev/en/stable/userguide/tasks.html#Task.track_started
Hey PJ - that's what I needed. Wonderful answer, thank you so much!
Will attempt a PR on this project for the documentation to mention the celery settings track_started
in relation to date_created
.
Thanks again!
I will be happy to accept any PR to improve the docs. thanks in advance
wonderful resolution, btw does adding this argument in shared task will make it slower?
Hi there - am having the issue described in the title (results
date_created
almost the same asdate_done
) despite tasks taking several seconds or minutes).I was hoping the
date_created
to be the creation date of the task, but I now realise it's the creation date of the task result itself (due to theauto_now_add
flag in the model definition).@bigott-a seems to have the same issue: https://github.com/celery/django-celery-results/issues/87#issuecomment-1041524877
In the link above, @steresi seems to imply that the TaskResult record is created first (setting the
date_created
correctly), then updated when the task is completed (setting thedate_done
correctly) - which is not what I observe. In my setup, the TaskResult record is only committed to the database after the task has completed.Is there something I am missing here? Could difference in settings explain this? Thanks!