0

In one of my celery tasks, I'm creating database entries. I know how to read the status of my celery tasks :

from celery.result import AsyncResult
res = AsyncResult("my-task-id")
res.ready()

But I want to know that exactly which database entry was created on a specific task by using a celery task ID. How can I do this?

Thanks in advance.

Taohidul Islam
  • 5,246
  • 3
  • 26
  • 39
  • 1
    You may need to add a flag in the model, which indicate the source od creation – JPG Dec 12 '19 at 04:49
  • 1
    Try this http://docs.celeryproject.org/en/latest/faq.html#results and https://stackoverflow.com/a/5544834/4751726 – shafik Dec 12 '19 at 04:52

1 Answers1

4

When you insert new database entries, you will get the IDs of those newly inserted rows from your query.

Celery tasks can return "results". After inserting the database entries, just return those id / ids.

You can now retrieve the result of a task by task id to get the database ids.

masnun
  • 11,635
  • 4
  • 39
  • 50