I am new to Django and the django-background-tasks package.
I am facing an issue that I couldn't do/start background task unless I forcefully run the command process_tasks
, that is python manage.py process_tasks
. I want to do/start background task without run the process_tasks
command.
settings.py
MAX_ATTEMPTS=1
BACKGROUND_TASK_RUN_ASYNC = True
tasks.py
from background_task import background
#included necessary packages for SMTP
@background(schedule=5)
def test():
#send mail to some ids
views.py
def index(request):
test(schedule=5)
return HttpResponse("Hello, world. ")
Ignore my logic.
Well you could make a bash script that makes the process_tasks call and call that script from python
to call the script from python you can use
as its explained here Running bash script from within python
your bash script may look something like this
dont forget to make process_tasks.sh executable