django-background-tasks
django-background-tasks copied to clipboard
Remove the associated process when a task is deleted
If a task is deleted before the process associated with it finishes, i.e. canceled by the user, kill that process.
This can be done by overriding the delete() method of the Task model.
@onurmatik I'm interested - how would this be coded?
I don't see how this should work.
It's just a python method running within a thread.
There is no thread sync and no process to kill gracefully.
Implement smaller atomic methods and chain them.
Let an atomic task of your big program trigger the next small task just before finishing.
save_user -> update_index -> blah_1 -> blah_2
I have tasks taking a long time, and much resources. It's about planning many emails to be sent somewhen in the future, and it cannot be "atomized"...so when a planning task is not yet finished, but should aborted and restarted (let's say more emails, or, none anymore...), it could be really helpful to not wait before planning can start again from the beginning.
I can see processes that are spawned, when using async mode, so killing the process that started a task would be a solution? a bit drastic though. I dont know anything about threads and multiprocessing in python, so...maybe I'm completely wrong :-)