lilspikey / django-background-task

A database-backed work queue for Django
BSD 3-Clause "New" or "Revised" License
107 stars 200 forks source link

When scheduling tasks, is it possible to get the id of the Task database object that has been created? #6

Open stargazer opened 12 years ago

stargazer commented 12 years ago

When scheduling tasks, is it possible to get the id of the Task object that has been created in the database? That would be really useful, since it would enable us to cancel the scheduled task, simply by deleting the object.

lilspikey commented 12 years ago

It's not currently possible (it's currently fire and forget). I'll look into returning an object that would let you get the id when you schedule a task (currently None is returned).

lilspikey commented 9 years ago

One things that occurs to me about this is being careful not to delete a task that's actually in the process of being run. We'd probably need to lock the task (in the same manner as the worker process) before deleting to avoid this issue. Plus we'd need to report back whether the deletion was successful or not. For tasks scheduled in the future it should always work, but there is the edge case of tasks that are getting cancelled just as they are about to run...