django-background-tasks
django-background-tasks copied to clipboard
Tasks aren't run from code that hasn't already been imported
I ran into this issue with using django_vox in a project. Django Vox has optional support for using background_task
so that you can delay message sending. There was an API update though, and now I'm running into this issue.
As far as I can tell, the problem is that function that's decorated with background_task.background
needs to be imported before process_tasks
will pick it up. Because the default design with Django Vox is to lazy-load this function, it doesn't get picked up in our cron job that runs process_tasks
.
I have the same problem. I just import the files containing the tasks in my models.py file. It works, but it is not really beautiful. And it should be noticed in the docs.